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

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 ...

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