Skip to content

Instantly share code, notes, and snippets.

@tobiasstraub
Created November 22, 2014 14:24
Show Gist options
  • Save tobiasstraub/a7039064903886584901 to your computer and use it in GitHub Desktop.
Save tobiasstraub/a7039064903886584901 to your computer and use it in GitHub Desktop.
Android: Dialog with positive and negative Button
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
builder.setTitle(R.string.dialog_title);
builder.setMessage(R.string.dialog_message);
builder.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO: Do something, when user click on the positive button
}
});
builder.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialog, int which) {
// TODO: Do something, when user click on the positive button
}
});
builder.create().show(); // Create the Dialog and display it to the user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment