Only to close this report.
I followed the Erel video to get Index, ID and valueName.
Sub Globals
Private B4XComboBox3 As B4XComboBox
Dim Label3 As Label
Private MapValues As Map
Private ListNames As List
' Data can come from a table, database or from anywhere
' Data to load (left ":" is ID, right, is Value or Name to be displayed)
Dim CBPreg2(7) As String
CBPreg2(0) = "15:2do Apellido abuela materna"
CBPreg2(1) = "23:Nombre primer mascota"
CBPreg2(2) = "37
asatiempo favorito"
CBPreg2(3) = "99:Juguete preferido de tu niñez"
CBPreg2(4) = "113:Sobrenombre que tenías"
CBPreg2(5) = "980:Nombre de tu mejor amigo(a)"
CBPreg2(6) = "1320:Ciudad Europea que quieres visitar"
End Sub
Sub Activity_Create(FirstTime As Boolean)
LoadData
End Sub
Sub LoadData
MapValues.Initialize
ListNames.Initialize
Dim k As Int
For J = 0 To CBPreg2.Length - 1
k = CBPreg2(J).IndexOf(":")
Dim name As String = CBPreg2(J).SubString(k + 1) 'RIGHT
MapValues.Put(name, CBPreg2(J).Substring2(0, k)) 'LEFT ' fill MapValues (Map type)
ListNames.Add(name) ' fill ListNames (List type)
Next
' Populate Combo
B4XComboBox3.SetItems(ListNames)
End Sub
Sub B4XComboBox3_SelectedIndexChanged (Index As Int) ' It comes here after item click
Dim name As String = B4XComboBox3.GetItem(Index)
Dim idValue As Double = MapValues.Get(name)
Label3.Text = name & " " & idValue ' name and idValue are displayed in this Label
End Sub