Android Example [B4X] AS TextFieldAdvanced - ComboBox


In this example I will show you how to quickly and easily turn the TextField into a ComboBox.

2024.03.12_0550-ezgif.com-resize.gif
AS_TextfieldAdvancedComboBoxExample.gif
AS_TextfieldAdvancedComboBoxExample.gif


1. Set the Mode to "ComboBox" in the designer
1710281829928.png

2. Add Items to it
B4X:
    Dim lst_Items As List
    lst_Items.Initialize
    lst_Items.Add("Item #1")
    lst_Items.Add("Item #2")
    lst_Items.Add("Item #3")
    lst_Items.Add("Item #4")
    lst_Items.Add("Item #5")
    
    AS_TextFieldAdvanced1.SetItems(lst_Items)
3. Done

SelectedIndex
To select a specific item, there is the SelectedIndex property.
B4X:
AS_TextFieldAdvanced1.SelectedIndex = 2

Events
if an item has changed, the ComboBoxSelectedIndexChanged event is triggered.
B4X:
Private Sub AS_TextFieldAdvanced1_ComboBoxSelectedIndexChanged(Index As Int)
    Log("Selected Item Text: " & AS_TextFieldAdvanced1.Text)
End Sub
 

Attachments

  • AS TextFieldAdvanced ComboBox Example.zip
    179.5 KB · Views: 69
Top