Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps
by Derek Walter, Mark Sherman
Working with Lists
When you have a list (it can be empty, too), you can do something with it. For starters, you can add a new item to the end of the list. If the list had n items before, then after you add the new one, it will have n+1 items; the last item will be item number n+1. This is done with the block add items to list.
You can get the number of items in the list using the length of list block. It’s often useful to know how long a list is so you don’t try to ask for data that’s not there. If you ever ask for an item that doesn’t exist, the app will create an error, which the user will see. For example, if a list has five items and you try to get item number 6 (or higher), that item doesn’t exist and thus will trigger an error. Try not ...
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