O'Reilly logo

App Inventor by Ellen Spertus, Liz Looney, Hal Abelson, David Wolber

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

Chapter 19. Programming Lists of Data

image with no caption

As you’ve already seen, apps handle events and make decisions; such processing is fundamental to computing. But the other fundamental part of an app is its data—the information it processes. An app’s data is rarely restricted to single memory slots such as the score of a game. More often, it consists of complex, interrelated items that must be organized just as carefully as the app’s functionality.

In this chapter, we’ll examine the way App Inventor handles data. You’ll learn the fundamentals of programming both static lists (in which the data doesn’t change) and dynamic lists (in which the data is user-generated). Then you’ll learn how to deal with even more complex data involving lists whose items are also lists.

Many apps process lists of data. For example, Facebook processes your list of friends. A quiz app works with a list of questions and answers. A game might have a list of characters or all-time high scores.

List variables work like text and number variables you’ve worked with, but instead of the variable representing a single named memory cell, it represents a related set of memory cells. Consider, for example, the list of phone numbers in Table 19-1.

Table 19-1. A list variable represents a set of memory cells

111–2222

333–4444

555–6666

The elements of a list are accessed using an index. An index is a position in a list, so index 1 of the list ...

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