Performing multiple selections from a list
This recipe will show a list of items on an Android device, allowing you to select more than one item from the list, hence enabling multiple selections from the list.
How to do it...
In this recipe, we will be making use of the following methods:
dialogCreateAlert()
: To display a message via the dialog boxdialogSetMultiChoiceItems()
: To define the array of items to be displayed in list format in the dialog for multiple selectionsdialogSetPositiveButtonText()
: To display a button in the dialog box to indicate that all selections are completedialogGetSelectedItems()
: To get the array of selected items
Take a look at the following steps:
- Type the following code in the Python script
demoMultipleSelection.py
in the current folder of your computer:
import android
app = android.Android()
app.dialogCreateAlert("Select your food items")
app.dialogSetMultiChoiceItems(['Pizza', 'Burger', 'Hot Dog'])
app.dialogSetPositiveButtonText('Done')
app.dialogShow()
app.dialogGetResponse...