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: 293

Alexander Stolte

Expert
Licensed User
Longtime User
Hello! How can I change dropdown color? Thank you!
Search the forum for "b4xcombobox color" and wait for the next textfield update, then you can access the native combobox. And next time, please create a new thread for every question you have.
 
Top