Skip to content

Instantly share code, notes, and snippets.

@smaugho
Last active May 4, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smaugho/1238a63c8a1caf14989f26c728a83c6a to your computer and use it in GitHub Desktop.
Save smaugho/1238a63c8a1caf14989f26c728a83c6a to your computer and use it in GitHub Desktop.
AlertDialog action example
//Showing AlertDialog with a message and a title
//----------------------------------------------
$AlertDialog().title("Example")
.message("This is an example")
.positiveButton("OK");
//Showing a "Rate this app" message using Strings resources
//---------------------------------------------------------
$AlertDialog().message(R.string.rate_this_app)
.positiveButton(R.string.yes)
.negativeButton(R.string.no)
.neutralButton(R.string.ask_later);
if ($AlertDialog.PositiveButtonPressed){
//To rate the app
}
if ($AlertDialog.NegativeButtonPressed){
//The user doesn't want to rate
}
if ($AlertDialog.Dismissed) {
//Continue to the next screen in the app
}
//Displaying a select with any object (it uses the object toString method)
//------------------------------------------------------------------------
@Model
List<User> users;
$AlertDialog().title("Select User").items(usersList);
if ($AlertDialog.ItemSelected) {
$Toast("The user selected was: {usersList[position]}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment