Prompt.promptOptions()
Overview
Displays a dialog box that prompts a user with button options. This function is asynchronous and will return before the response is given. Use the callback parameter to handle results.
Added in version 2.0.1
Format
Prompt.promptOptions(title, message, options, resultDelegate);
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
title | A title to display for the dialog. Can be null or an empty string if no title is desired. | String | Required | |
message | The message to display in the dialog box. | String | Required | |
options | Button options for the user to select. | String | Required | Separate options with a | character. |
resultDelegate | A function that takes a single string result parameter that is called when the user responds to the prompt. When the user selects an option that value will be returned. | Function with a single String parameter | Required |
Example
Copy
/* Prompt the user to choose 'Dog', 'Cat' or 'Bird'.
*/
Prompt.promptOptions("Favorite Animal","Choose your favorite animal.", "Dog|Cat|Bird", function (result) {
if(result === 'Dog') {
View.toast('bark', true);
}
if(result === 'Cat') {
View.toast('meow', true);
}
if(result === 'Bird') {
View.toast('tweet', true);
}
});