Skip to content

Instantly share code, notes, and snippets.

@rajohns08
Last active May 5, 2016 03:45
Show Gist options
  • Save rajohns08/e4aacf98726213db2714 to your computer and use it in GitHub Desktop.
Save rajohns08/e4aacf98726213db2714 to your computer and use it in GitHub Desktop.
Android - ActionAlert dialog for yes/no type of dialog where the user is asked to confirm some action or cancel
public class ActionAlert {
public static void show(Context context, String title, String message, String actionText, DialogInterface.OnClickListener actionCallback) {
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(message)
.setPositiveButton(actionText, actionCallback)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment