Reputation: 377
I have a login screen, when in click on login button then a pop up is displaying with Ok. My need is to hold the pop up till Ok click.
Upvotes: 0
Views: 1913
Reputation: 608
This is way:
AlertDialog alertDialog = new AlertDialog.Builder(
AlertDialogActivity.this).create();
// Setting Dialog Title
alertDialog.setTitle("Alert Dialog");
// Setting Dialog Message
alertDialog.setMessage("Hello ,");
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Write your code here to execute after dialog closed
//Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
alertDialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
Upvotes: 1
Reputation: 1362
you can do this by using
setCancelable(false)
like this
AlertDialog.Builder builder = new Builder(context);
builder.setMessage("Some Message");
builder.setTitle("You Title");
builder.setCancelable(false);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//I won't add finish() here
}
});
builder.create().show();
Upvotes: 0
Reputation: 4117
do like this
public static void showMessageDialogWithIntent(final Activity activity, String Message, final String intentClassName) throws ClassNotFoundException {
Log.e(TAG, "showMessageDialogWithIntent");
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage(Message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
try {
// do work here
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
builder.setCancelable(false);
builder.create().show();
}
Upvotes: 1