O'Reilly logo

Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps by Mark Sherman, Derek Walter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Properties: Getters and Setters

To use a component property as a variable, we need to be able to get the current value and set a new value. This is done with blocks called, logically, getters and setters. They are available in the flyout menu for each component (see Figure 4.2).

Image

Figure 4.2 The getter and setter blocks for TheButton’s Text property.

Here’s the idea: Every time the button is clicked, we will get the current value that’s in the text property, change it to be 1 greater, and then set that value back into the property. It will update the property to have the new number in it, which will appear on the screen.

That idea translates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required