App Inventor programmers routinely store values, such as numbers or text strings (“Hello!”) in variables. For example,
stores the numeric value 6 in to the variable TOTALBUTTONS.
To illustrate by example, here is a global variable named SpecialButton. We can initialize it to anything we want at this point.
Next, inside our app, our blocks code assigns Button1 to the variable SpecialButton. SpecialButton now holds a reference to the actual user interface control Button1.
Since SpecialButton is a variable and not an actual button, we cannot directly use a SpecialButton.Click handler but we can use a feature of App Inventor to do the same thing in a different way. We will see how to do this in this a bit later.
You can store any App Inventor components – a Clock, a Bluetooth device – any component, in a variable.
Why would you want to do that? We will see in the example in this lesson.
This tutorial is in both written form and as an online video.
Continue reading Part 1: Storing and accessing user interface components as variables