AppInventor: Membuat Daftar / List 1

From OnnoWiki
Jump to navigation Jump to search

Sumber: http://www.appinventor.org/content/howDoYou/ListNav/next


Example 1. How do you create a slideshow so the user clicks to get to the next picture? example 2

In this example, the user clicks a button to sequence through a slideshow of pictures. The pictures are in the media files pic1.jpg, pic2.jpg, and pic2.jpg, all of which have been loaded into the app. The variable index is defined to keep track of the current picture the user is viewing. When the user clicks “Next”, the index is checked to see if the user has gone too far. If index is less than the length of the list (3 in this case), then the index is incremented and the next picture file is placed into Image1.Picture.

Let’s walk through this example. Assume that pic1.jpg is showing to start. When the user clicks “Next”, index is checked and is less than the length of the list (1<3). So index is incremented from its initial value, 1, to 2, and pic2.jpg is selected and displayed.

The next time the user clicks “Next”, index is 2 so it is still less than 3, so index is incremented to 3 and the third picture, “pic3.jpg”, is displayed.

When “Next” is clicked again, index is 3 so the if-test fails. The blocks within the if are not executed, so nothing happens. In fact, the user can continue to click “Next” forever with no effect.


Appinventor-list3.png



Referensi