B4J Question [SOLVED] Documentation with explanation how ComboBox and ChoiceBox work?

christianjeannot

Member
Licensed User
When I search the forums and check several discussions and examples it is getting confusing.

I see sometimes

B4X:
Dim cb as ComboBox

B4X:
Dim cb as B4XView

B4X:
Dim cb as B4XComboBox
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    ComboBox1.Items.Add("Item 1")
    ComboBox1.Items.AddAll(Array("2", "3", "4"))
End Sub

Private Sub ComboBox1_ValueChanged (Value As Object)
    Log(Value)
End Sub

ComboBox and ChoiceBox are native B4J controls.
B4XComboBox is a custom view that is included in XUI Views. If you are interested in cross platform development then B4XComboBox is the best choice. Under the hood it is a regular ComboBox in B4J.

All native views can be cast to B4XView (and vice versa). More information here: [B4X] [XUI] Cross platform & native UI library
 
Upvote 0

christianjeannot

Member
Licensed User
Hello Erel,

thank you for your information and example code.

I have a problem of understanding. Maybe also less experience.

I have checked the link. You say


And here is my problem of understanding.

When I use

B4X:
Private ComboBox1 As ComboBox

I can use
B4X:
ComboBox1.Items.Add("Item 1")


When I use
B4X:
Private ComboBox1 As B4XComboBox
this is not possible. The method
B4X:
Items.Add("Item 1")
is not there.

I want to create an App which runs on Android, iOS and Desktop. If ComboBox is for B4J my idea/undestanding was that I should use B4XComboBox but how can I add items when .Items.Add is not available?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…