Set state of a Button

43 views
Skip to first unread message

ioana...@gmail.com

unread,
May 21, 2014, 6:25:05 AM5/21/14
to codenameone...@googlegroups.com
Hello!

I need to set the state(pressed/unselected) of a Button programmatically:
 
- when I click on a button I want it to remain pressed.
- Then when I click on another CERTAIN button, I want to unselect the first button and set the other to be pressed.

I found this: button.pressed();  
which makes my button stay pressed but when I press on another button, it gets unselected. I don't want this to happen. I just want to set a button's state pressed and unselected whenever I want.

Thanks!

Shai Almog

unread,
May 21, 2014, 12:52:30 PM5/21/14
to codenameone...@googlegroups.com, ioana...@gmail.com
Hi,
create a radio button and set it to toggle button mode. Add them to the same button group and they will toggle each other.
You can do the same for checkboxes.

ioana...@gmail.com

unread,
May 27, 2014, 3:40:27 AM5/27/14
to codenameone...@googlegroups.com, ioana...@gmail.com
Hi Shai,

Thank a lot! I used RadioButtons and I managed to create the effect I wanted, thanks!!
Reply all
Reply to author
Forward
0 new messages