TalkToMe: Your first App Inventor app -
Save all the phrases you enter.
How can you save all the phrases that we’re telling the app to speak? We need a way to “store” the text that
we type into the TextBox. Here’s how you can do that with a list.
Lists are exactly what they sound like they should be. They keep track of certain items. For example, you
may track the grocery items you need to buy in a list. Let’s call this list “groceries”.
Each of these items is “indexed,” meaning you can ask to get item number 1 from this list and you will get
“apples.” If you ask for item number 2, you’ll get “oranges,” and so on.
In App Inventor, every time you add an item to the list, you are “appending” to the list, or putting another item
on the end of the list. For example, if I wanted to add “bananas” to the list, the final list would look like this:
Adding items to the list does so without discrimination. This means that if an item already exists, you can
add a duplicate. If I wanted to add “oranges” to the list, I could do so and end up with the following:
As a result, asking for item number 2 will return “oranges,” but asking for item number 5 will also return
“oranges.” In order to avoid this, you can first check if this item “is in list?” This block will return true if the
item already exists in this list, and false if it doesn’t.