Android Question B4A - Inputmap

SOPET

New Member
Licensed User
Hi guys... as newbie here and also to B4A Iwant to do my first question:

I have a MaridaDB Table with products with DESCRPTION and an ID. I have put those using Inputmap because Iwant user to select multiple products. The question is how i can get product's selected list in order to use ID's to the next screen to load other things from another table.

Thank you in advance.

PS: Glad to be here
 

keirS

Well-Known Member
Licensed User
Longtime User
Use two maps. One Map for the InputMap with the description and if it is selected and one map with the description as the key and the ID as the value. As long as the maps have the items at the same index then you can "map" your inputmap map to your description/id map.
 
Upvote 0

SOPET

New Member
Licensed User
Use two maps. One Map for the InputMap with the description and if it is selected and one map with the description as the key and the ID as the value. As long as the maps have the items at the same index then you can "map" your inputmap map to your description/id map.
Thanks for youor answer. It sounds like a smart "tricky" solution.
Somewhere I had read that Inputmap can return a list with the selected items after pressing "OK". Is that true ? if yes, how I can do that ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Process_Globals
   Type Item (Name As String, Id As Int, Description As String)
   Private AllItems As Map 'should be in the starter service
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     AllItems.Initialize 'should be in the starter service
     For i = 1 To 100
       Dim Item As Item
       Item.Initialize
       Item.Id = i
       Item.Name = "Item #" & i
       Item.Description = "sadasdasd"
       AllItems.Put(Item.Name, Item)
     Next
   End If
   Dim selected As List = SelectItems
   Log(selected)

End Sub

Sub SelectItems As List
   Dim res As List
   res.Initialize
   Dim m As Map
   m.Initialize
   For Each name As String In AllItems.Keys
     m.Put(name, False)
   Next
   InputMap(m, "Select items")
   For Each name As String In m.Keys
     If m.Get(name) = True Then res.Add(AllItems.Get(name))
   Next
   Return res
End Sub
 
Upvote 0
Top