ListPicker and Choosing from a List of Lists

Lists, indexes, iterating through a list

Printable Version

The ListPicker component

The ListPicker lets the user choose from a list of items. It has an associated button-- when the button is clicked, the chooser appears.

Key Properties

ListPicker.Elements  -- set this to the list you want to appear

ListPicker.Selection  -- when the user chooses, this is their choice

ListPicker.SelectedIndex  -- when the user chooses, this is the index of their choice

Key Events

ListPicker.BeforePicking -- this is triggered when the user clicks the ListPicker button.

       Typically you’ll set the ListPicker.Elements property here.

ListPicker.AfterPicking -- this is triggered when the user makes a choice.

Challenge

add a list variable with some items, and a ListPicker and Label. Code the BeforePicking to set the Elements, and in the AfterPicking just put the answer in the label.

List of Lists

Consider a quiz app and suppose you want to have multiple choice. Then for every question you need both an answer and a list of answer choices. The list of answer choices is actually a list of lists:

img00

1.Suppose you wanted to place the second answer choice of the first question of a quiz into a label. Sketch the blocks. You’ll need the selectListItem block:

img01

2. Suppose you were creating a multiple-choice quiz and you had an index variable which kept track of the current question (and answer). Sketch the blocks for displaying the answer choices for the current question in a ListPicker.

Reading: http://www.appinventor.org/Chapter19, near end

appinventor.org course-in-a-box                                        

This document is licensed under an Attribution-NonCommercial-ShareAlike 3.0 Unported License