civ...@gmail.com

unread,
Mar 23, 2014, 12:40:51 PM3/23/14
to mitappinv...@googlegroups.com
Hello, I have a simple question: I have 3 CheckBox with initial state check, uncheck, uncheck; I want check only and only one as a group radio buttons, how is possible with appinventor 2 ? I cannot be able to write the code with app inventor 2, thanks.

SteveJG

unread,
Mar 23, 2014, 2:52:49 PM3/23/14
to mitappinv...@googlegroups.com, civ...@gmail.com
AI2 does not have a radiogroup control.  You probably can simulate one using the CheckBox

You will need some Control and Logic blocks.       In pseudo-code, the logic would go:

In Checkbox1.    
 if checked = true
then
     Checkbox2checked=false
      Checkbox3.checked=false
     (the block of what you want to switch or control with Checkbox1 goes HERE)
else if
    checked = false
then
      

and similar code in Checkbox2 and 3.

Experiment about..how to do this exactly is not intuitive.

I would place all three controls in a Table Layout block.    

Did this help?   Let us know, show us some block images if you get stuck.

Regards,
Steve

Enis

unread,
Mar 23, 2014, 5:14:42 PM3/23/14
to mitappinv...@googlegroups.com, civ...@gmail.com
I played with this a tiny bit before I had to go out... Here's your dilemma.  If you put code to turn off the other checkboxes in each block, that will trigger them being changed too.

The only way I thin you'll be able to do this is to use a procedure with several variables, and use that to turn all of them on or off.  What you'll need to do is keep track of which one triggered the others, usiing a global variable, bypass the changes if you make them yourself in code.  In other words, I check box 1, but have to turn 2 & 3 off.  2 & 3 will each trigger a changed event, and you'll have some horribly cyclical loop that will simply crash when it runs out of memory or steam.

You'll probably have to trigger a global variable and use that in a proc to turn the others on, ignoring the action in the one that caused it...

Tough problem...

SteveJG

unread,
Mar 24, 2014, 2:05:17 PM3/24/14
to mitappinv...@googlegroups.com
Thank you for your interesting, I resolved !\

Thank you for letting us know Fabio!

-- Steve

beavis

unread,
Feb 7, 2015, 9:23:15 AM2/7/15
to mitappinv...@googlegroups.com
I know this is an old thread but found it in my search for checkbox behavior similar to radio group. It does work but I didn't like that that user could actually uncheck all boxes. A more accurate behavior would be the addition of another if/else that makes sure one box is selected at all times. It seems to work fine and hopefully will help anyone looking to simulate an actual radio group. My apologies if this has been covered somewhere else that I didn't notice.


SteveJG

unread,
Mar 3, 2018, 7:07:20 PM3/3/18
to mitappinv...@googlegroups.com
RadioGroup Check Boxes Solved.


This seems to work.   Is it what you needed.

Regards,
Steve
Reply all
Reply to author
Forward
0 new messages