Reputation: 87
I made an app ,and there is a progress dialog on one of its activities . I want to show an alert dialog , when progress dialog has finished. How can I do it?
please guid me...
thanks.
Upvotes: 1
Views: 1013
Reputation: 8023
I am assuming you already know how to show the progress dialog. The progress dialog has two listeners, onDismiss and onCancel. Check out the difference here : What is the difference between a dialog being dismissed or canceled in Android?
You can choose to put either of the listeners depending on your requirements. Here's a sample code.
progressDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Your Title");
// set dialog message
alertDialogBuilder
.setMessage("Message")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
});
Upvotes: 3