You need to look at the class, you will see there is a function that looks something like thisHi, With B4XComboBox, Does ItemClick event exist? and how about loading value and name for getting SelectedId
Private Sub RaiseEvent CallSub2(mCallBack, mEventName & "_SelectedIndexChanged", getSelectedIndex) End Sub
'Change cmbox to whatever name you gave when initializing the B4XComboBox variable cmbox_SelectedIndexChanged(Index as Int) End Sub
Thanks Walter, it worked fine.
I had tested but using (Index As Int, Value As Object) instead of (Index as Int) only.
So, my second question is about loading "Value and Name" instead of "Name" only. (Not Index).
Meanwhile, I will "fight" with MAP to get Value and Name through Index.
Public Sub GetItem(Index As Int) As String #if B4J Return cmbBox.Items.Get(Index) #Else If B4A Return cmbBox.GetItem(Index) #Else Return mItems.Get(Index) #End If End Sub
You can use something like this as entire code without having to deal with maps and substrings. If it does not meet your need, please ignore:Only to close this report.
I followed the Erel video to get Index, ID and valueName.
Sub Globals Private MyList As List Private B4XComboBox3 As B4XComboBox 'need xui views lib Private Label3 As Label End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") 'has 1 combobox and 1 label Dim CBPreg2(7) As String CBPreg2(0) = "15:2do Apellido abuela materna" CBPreg2(1) = "23:Nombre primer mascota" CBPreg2(2) = "37:pasatiempo 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" MyList.Initialize For i=0 To CBPreg2.Length-1 Dim s() As String =Regex.Split(":",CBPreg2(i)) MyList.Add(s(1) & " " & s(0)) Next ' Populate Combo B4XComboBox3.SetItems(MyList) End Sub Sub B4XComboBox3_SelectedIndexChanged (Index As Int) Label3.Text = B4XComboBox3.GetItem(Index) ' name & idValue displayed in this Label the way you want them End Sub