Android Question Various Ways to Select Multi Items

Mahares

Expert
Licensed User
Longtime User
Normally, I use one of these: CLVSelection extension, B4XTable Selection extension, xClv with checkboxes, InputMultiList (this one is not multi-platform). Can some of you cite their preferred methods and why.
Thank you
 

Mahares

Expert
Licensed User
Longtime User
Another one to consider is B4XDialog + ListTemplate.
B4XListTemplate does not seem suitable for a list like either of these 2 types of lists or don't I know what I am talking about:
B4X:
SettingsList.Add($"EvenRowColor,xui.Color_Cyan"$)
    SettingsList.Add($"OddRowColor,xui.Color_Yellow"$)
or this:
B4X:
SettingsList.Add(Array("OddRowColor", xui.Color_Yellow))
    SettingsList.Add(Array("GridColor", xui.Color_Red)
options.Options = SettingsList
The settings need to apply to a B4XTable.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The question in the first post is about lists that allow multiselection. B4XListTemplate supports multiselection and is my preferred method.
Yes. It is a good choice but I tried it in my situation and it didn't work like CLVSelection or XSelection of B4Xtable, unless I am overlooking something. So I am using either of the latter two.
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This can be done quite easily with an additional Map.
B4X:
SettingsList.Add(Array("OddRowColor", xui.Color_Yellow))   'SettingsList is the full list
    SettingsList.Add(Array("GridColor", xui.Color_Red))
    SettingsList.Add(Array("pnlHeader.Color", xui.Color_Cyan))
    SettingsList.Add(Array("HeaderColor", xui.Color_Green))
    SettingsList.Add(Array("HeadersHeight" , 70dip))
   MySelectionsList.Initialize   'declared as list of selected items
    options.Options = SettingsList   'options is declared as B4XListTemplate
    options.AllowMultiSelection = True  'allows multi selection
    Wait For (Dialog.ShowTemplate(options, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        MySelectionsList  = options.SelectedItems
    End If
Then I create the map to trigger and apply the settings selected to the B4XTable:
B4X:
Private Sub CreateSettingsMapFromSelections As Map
    Dim m As Map
    m.Initialize  
    For Each s() As Object In MySelectionsList
        m.Put(s(0),s(1))
    Next
    Return m
End Sub
Everything above works well in applying the settings to the B4XTable, but the problem is in displaying the full list to select from. See the attached screenshot as a result of using a list of arrays. Using a list of simple strings will not work.
1699289594238.png


Edited few hours later: I created a map whose keys are the B4XListTemplate items and their values are the corresponding B4Xtable settings. For instance the key is: OddRowColor and the value would be xui.Color_Yellow. Then I used the individual items from the list of all selected items.of the B4XListTemplate along with their corresponding values to create another map that I used for the settings of B4XTable. See newer screenshot not dealing with arrays. It seems to work. If this is not kosher, please advise:
1699316929750.png
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Edited few hours later: I created a map whose keys are the B4XListTemplate items and their values are the corresponding B4Xtable settings. For instance the key is: OddRowColor and the value would be xui.Color_Yellow. Then I used the individual items from the list of all selected items.of the B4XListTemplate along with their corresponding values to create another map that I used for the settings of B4XTable. See newer screenshot not dealing with arrays. It seems to work. If this is not kosher, please advise:
This is what I meant.
 
Upvote 0
Top