B4J Question Buttons to act like radio buttons

rodmcm

Active Member
Licensed User
I have 5 buttons. If I operate any one then I want the text and text colour to change for the non selected ones,
similar to how a radio button works. Is there an easy way to do this or do I have to address every other buttons
text and colour under a single button 'click'
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
Is there an easy way to do this
not particularly, but there are some strategies. all the buttons can share the same event

B4X:
public sub buttons_click
and you can know what button was triggered
B4X:
dim b as button = sender
then i would put the buttons in a list
B4X:
dim buttons as list = array as object(button1,button2,button3)

at the end just do a for each
B4X:
for each b2 as button in buttons
if b = b2 then
b2.something
else
b2.somethingElse
end
 
Upvote 1
Top