In this recipe, we will be making use of the following methods:
- dialogCreateAlert(): To display a message via the dialog box
- dialogSetMultiChoiceItems(): To define the array of items to be displayed in list format in the dialog for multiple selections
- dialogSetPositiveButtonText(): To display a button in the dialog box to indicate that all selections are complete
- dialogGetSelectedItems(): 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 androidapp = android.Android()app.dialogCreateAlert("Select your food items")app.dialogSetMultiChoiceItems(['Pizza', 'Burger', 'Hot Dog'])app.dialogSetPositiveButtonText('Done') ...