Skip to content

Instantly share code, notes, and snippets.

@tyaslab
Created February 7, 2016 23:32
Show Gist options
  • Save tyaslab/a5699e8f69a8cdd9f558 to your computer and use it in GitHub Desktop.
Save tyaslab/a5699e8f69a8cdd9f558 to your computer and use it in GitHub Desktop.
Android Snippet - AlertDialog
AlertDialog.Builder builder = new AlertDialog.Builder(getDialogContext());
builder.setMessage("Message");
builder.setPositiveButton("Yes", new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this, "Yes", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
builder.setNegativeButton("No", new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this, "Yes", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
builder.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment