Showing posts with label Alert Dialog in Android. Show all posts
Showing posts with label Alert Dialog in Android. Show all posts

Tuesday, August 18, 2015

Alert Dialog in Android

show alert dialog in Android for validation or other purpose, show alert dialog with message and when click on Ok then Dismiss.

it pop up on screen and display message.

Context context;
String message;
AlertDialog alert = null;

AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(message)
      .setCancelable(false)
      .setPositiveButton("OK", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
          alert.dismiss();
          }
      });
alert = builder.create();
alert.show();
}