B4J Question B4J B4XView ComboBox Can't Add Items

DonRacz

Member
Licensed User
Longtime User
Getting Message "Unkown member : Items"

How do I add entries into the Combobox with being able to access Items member.

Thank
Don

Code:
Private cb1 As B4XView

cb1.Items.AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
 

DonRacz

Member
Licensed User
Longtime User
I addedXUI Views to the Libray, used your example

Still does not show "Items" in the list.

I have no doubt I'm missing a step somewhere but I have no Idea what it is.

it compiles fine but I get an error upon execution > java.lang.reflect.InvocationTargetException
 
Last edited:
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Where do you create the B4XCombox view? It needs to be done in Designer.
Open designer, add custom view, select B4XCombobox, rename to cb1 (press enter), make it taller. Save as "combo".
Select tools, generate members, expand and select B4XCombobox and event.

In B4XMainPage where it says load layout, change name to "combo".
Then use code in post # 3. Don't define bc1 again in code.

If this is new to you, download and review booklets by @klaus.

https://www.b4x.com/android/files/Booklets.zip
 
Upvote 0

DonRacz

Member
Licensed User
Longtime User
Where do you create the B4XCombox view? It needs to be done in Designer.
Open designer, add custom view, select B4XCombobox, rename to cb1 (press enter), make it taller. Save as "combo".
Select tools, generate members, expand and select B4XCombobox and event.

In B4XMainPage where it says load layout, change name to "combo".
Then use code in post # 3. Don't define bc1 again in code.

If this is new to you, download and review booklets by @klaus.

https://www.b4x.com/android/files/Booklets.zip
add "custom" view? All I Show is Add View
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
drop down list of that shows all views, including custom view, select that and you'll get another list, select B4XCombobox
 
Upvote 0

DonRacz

Member
Licensed User
Longtime User
drop down list of that shows all views, including custom view, select that and you'll get another list, select B4XCombobox
I'm building a sample project to show the problem.
If I select Select B4XPages as project type,
Custom Views is dimmed out in the Designer drop down.
I added XUI Vies to Library and it shows up....
 
Last edited:
Upvote 0

DonRacz

Member
Licensed User
Longtime User
I'm building a sample project to show the problem.
If I select Select B4XPages as project type,
Custom Views is dimmed out in the Designer drop down.
I added XUI Vies to Library and it shows up....
Got It Working! Thanks for all the help.

Don
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
It sounds like you prefer to learn experientially, like I do. The IDE has many helpful features. Don't hesitate to click on things.
You'll get used to the various paradigms quickly. However, I often go back to the booklets by @klaus. They're are a fixed icon on my desktop.
Also I have come to enjoy reading posts on this Forum on a regular basis.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Glad you got it sorted out with Willy's help. Here is more stuff to throw at you:
These 3 variants are equivalent:
B4X:
Dim cb As Spinner= B4XComboBox2.cmbBox
cb.AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.SetItems(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.cmbBox.As(Spinner).AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
 
Upvote 0

DonRacz

Member
Licensed User
Longtime User
Glad you got it sorted out with Willy's help. Here is more stuff to throw at you:
These 3 variants are equivalent:
B4X:
Dim cb As Spinner= B4XComboBox2.cmbBox
cb.AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.SetItems(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.cmbBox.As(Spinner).AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Thanks,
I will give them a shot.
 
Upvote 0

Pelky

Active Member
Licensed User
Longtime User
Glad you got it sorted out with Willy's help. Here is more stuff to throw at you:
These 3 variants are equivalent:
B4X:
Dim cb As Spinner= B4XComboBox2.cmbBox
cb.AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.SetItems(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
Or:
B4X:
B4XComboBox2.cmbBox.As(Spinner).AddAll(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
It is indeed a superb and very useful tool however I do have a problem with it. Having selected an item and then saving it away I want to be able to set the combox to that choice later. I cant find a way to do that. I tried setting the index and setting selected but always comes up with the initial setting. Any ideas?
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Please post this in a new thread, with a small example.

This works here, so there must be other issues.

B4X:
B4XComboBox1.SetItems(Array("Off","Steady","Xmas 1","Xmas 2","Help","Flash", "Wave"))
B4XComboBox1.SelectedIndex = 2
 
Last edited:
Upvote 0
Top