Skip to content

Instantly share code, notes, and snippets.

@ltpitt
ltpitt / AndroidAlertDialogExample.java
Created May 29, 2017 21:13
A simple AlertDialog in Android
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage("Alert message to be shown");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();