Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps
by Derek Walter, Mark Sherman
Lists that Expand on Demand
In most of this book, we’ve kept all our data either in properties of components or in global variables. These work great, but they have a limitation: They can’t expand. Sometimes we don’t know how much information we will need to store, and that’s another great use for lists.
The one-dimensional list we discussed earlier in this chapter is perfect for when we need our information to grow. With just one list, we can store any number of items in it.
Consider the contacts app we started imagining in the last section. The user might have 5 friends, or 50, or 500; our app should be able to handle all of them with no problem.
Clearly, we can’t make a global variable for each contact. We can’t guess how many friends the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access