Search code examples
androidapp-inventordynamic-list

App Inventor - Input an item to a list and then properly display the list


I recently started learning to use App Inventor to create some very primitive apps. I came across this project. Basically, I want to input the item to a list and then use the foreach iteration to properly display the list. However, the results are duplicate. It's as if every time I click the "add" button, the foreach iteration is executed. I spent several hours to search and also think about it, but I cannot figure out a way to solve this problem. Guess I have no talent but luckily I believe in efforts, too.

Here is a screenshot of the blocks and emulator/symptoms. Please let me know if more information is needed. I am a first-time user on stackoverflow and apologize ahead if I'm doing anything wrong. Thank you all in advance!

To explain the screenshot:

First, I enter "a" and hit add button, the list shows as "1.a"; I then enter "b" and hit add button, the list shows as "1.a 2.a 3.b", instead of "1.a 2.b"; finally, I enter "c" and hit add button, the list shows as it is shown in the screenshot...

Screenshot enter image description here


Solution

  • In your procedure displayList some initialization is missing... just add
    set LabelDisplay.Text to "" (empty string) and
    set global entreeNum to 0