Android Question catch SelectedIndexChanged event from custom control

lare

Member
Hi!

Is it possible to capture a SelectedIndexChanged event from a B4XComboBox that is in a custom control?

I looked at an example for a button and a limit bar that have SingleClick, DoubleClick, and ValuesChanged events but I need it for the SelectedIndexChanged event?

Thanks!
 

Attachments

  • ComboBox.zip
    65.8 KB · Views: 155

Peter Simpson

Expert
Licensed User
Longtime User
Hello @lare
You should watch some of the video tutorials under learn (top of this page), once of the videos is about the IDE and letting the IDE auto create your sub events for you.

I get the IDE auto create subs for me.
B4X:
Sub LocalB4XComboBox_SelectedIndexChanged (Index As Int)
    Log(LocalB4XComboBox.GetItem(Index))
End Sub

Logger connected to: Google Pixel 4 XL
--------- beginning of main
Copying updated assets files (9)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
2222
1111
44444

Using the designer (Or you can get the IDE to auto create the correct sub vent for you)
 
Upvote 0

lare

Member
Hi @Peter Simpson
I do not have problem with getting SelectedIndexChanged event of LocalB4XComboBox. I know that IDE can generate for me sub events. In the demo project that I attached, if you run it it works perfectly fine.


But I have problem, that I do not know how to do that same, with the B4XComboBox which is placed in custom control?!? It looks like that event (CustomCB1_SelectedIndexChanged) is never fired up, when I changed values in that combobox?
 
Upvote 0

lare

Member
Sorry Erel if I don't understand You, but did You mean that I can not make my custom view that consist of another custom view(in this case B4XComboBox)?

I added my custom view through the designer. I followed your example of 'LimitBarDemo2' and did the same.
I added New Module/Class Module/Custom View named it CustomCB and then I in designer add it on Layout(Add View/CustomView/CustomCB).
Then I define in Custom View class 'CustomCB' what I needed. But that is bad practice I suppose.




But then how I can use this of mine custom view on multiple activity if I need it???
If I add B4XComboBox directly on the activity like I did with LocalB4XComboBox then I can not easily reuse it?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…