Android Question Using B4XComboBox

Sergey_New

Well-Known Member
Licensed User
Longtime User
I ask you to make an example of using B4XComboBox for B4A. I saw a videolesson from Erel, but for those who do not know English it is difficult to understand (
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Did. The code works, but cmb is underlined, meaning it is not initialized. Why?
B4X:
Sub Globals
    Dim cmb As B4XComboBox
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout(1)
    Dim lst As List
    lst.Initialize
    For i=0 To 8
        lst.Add(i)
    Next
    cmb.SetItems(lst)
End Sub
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thank you, you are right!
 
Last edited:
Upvote 0

vmag

Active Member
Hello! And I also get B4XComboBox not initialized and the program hangs on the phone, why?
1. Created a new B4XPages in B4A.
2. Checked that everything works on the device (received a message on the button- Hello World!)
3. Added B4XComboBox in the constructor, checked on the device- it appeared.
4. Added the code:
B4X:
Sub Globals
    Public ChoiceR As B4XComboBox
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
        
    Dim lst As List
    lst.Initialize
    For i=0 To 8
        lst.Add(i)
    Next
    ChoiceR.SetItems(lst)
End Sub
The program is installed on the device, but when you start it freezes - there is no button or B4XComboBox,
sometimes writes that B4XComboBox is not initialized.
If you delete a line
B4X:
ChoiceR.SetItems(lst)
then everything works fine, but of course the B4XComboBox is empty and not active at all...
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
Add it to B4XMainPage:

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    Dim lst As List
    lst.Initialize
    For i=0 To 8
        lst.Add(i)
    Next
    ChoiceR.SetItems(lst)
End Sub
 
Upvote 0
Top