Command as a value in a variable

You can also move a command in AppInvetor to a variable, e.g. CheckBox1.Checked and then exchange it for another .... Box2, .... Box3. And then use the variable filled in this way? The point is that I don't have to use 10 procedures, but only one and change that command in a variable .....

Yes, this can be done using the component blocks as procedure parameters, and the Any Blocks inside that procedure.

1 Like

E.g. I want to use this block in some procedure. How should I replace e.g. CheckBox1 ..... Box2 ..... Box3 any variable?

Here is how to do the inner part:
Capture checkbox_list.aia (2.9 KB)



well thank you

How can I get that when I select one the others are not selected?

That's usually called a Radio Button.

It's equivalent to any one of the components

  • List Picker
  • ListView
  • that third component type whose name I forget because I don't like how its first item is treated differently from the others.

Any way, here's how to do it for just one radio button.
checkbox radio button demo checkbox_radio_button.aia (2.5 KB) Designer

If you have more than one radio button, pick one of the other component types, and go looking for a sample of a quiz.

I must admit to have overseen the "any" events. Thank you for that hint that makes me omit the specific event blocks "... changed". But while playing with those "any events" I do not completely understand the behaviour of that event block "when any CheckBox.Changed". Please, have a look at my example. In the past I used my function "RadioButtons" without problems especially in terms of that I understand a radio button as a button that induces when checked is true all other buttons of that same group becoming unchecked at once, without a second click on it.

checkbox_radio_button.aia (3.4 KB)


That is what my blocks are doing. I actually thought to be successfull with that "any" event concerning the "radio_button1". But I wasn't so. What's going wrong? To my results nothing happens with "Radio_button1" even if I add "if notAlreadyHandled" or so.

Whereas the following works:

Here is the buggy behavior you complained about ...
checkbox radio button demo

Here is why you are losing your checks in radio button 1 ...

The checkbox component sets the Checked Value true or false on its own, without the need for the CheckBox Changed event to do it.
Your circled code reverses what the AI2 component just did for itself.
Your procedure does not make that mistake.


Yes, I was blind!! Thank you very much! It works!

1 Like

Thank you very much!

I guess I didn't understand ....
Can anyone explain?
It can be "folded" e.g. this command:

when I know that I clicked on a certain CheckBox in the application ...
so I have the string "CheckBox1".