I wonder android support multiple dialog? Since when I first open the dialog. I allow user to click cancel, that will open one more dialog to confirm whether the user want to exit , the problem is if the user do not want to exit, the original dialog will disappear, how to fix the problem? Thanks
public static ProgressDialog showProgressDialog(final Context ctx, boolean isCancelable) {
ProgressDialog dialog = new ProgressDialog(ctx);
dialog.setCancelable(false);
dialog.setTitle(ctx.getResources().getString(R.string.system_info));
dialog.setMessage(ctx.getResources().getString(R.string.downloading));
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setProgress(0);
if (isCancelable){
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, ctx.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AlertDialog.Builder builder = new Builder(ctx);
builder.setMessage(R.string.cancel_offline_mode);
builder.setTitle(R.string.system_info);
builder.setPositiveButton(ctx.getResources().getString(R.string.confirm), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setNegativeButton(ctx.getResources().getString(R.string.cancel), null);
builder.create().show();
}
});
}
return dialog;
}
Update:
Here is what I would expected:
- The first dialog showing the download progress (eg. Downloaded 60% etc..)
- At the first dialog there is a cancel button, if click on it show the second dialog
- The second dialog ask whether confirm to cancel download
- If confirm, do cancel()...
- If not , return to the first dialog and show the percentage
Thanks
This is my function in which first of all dialog open which have says "take picture","Add Video"..when you click on "take picture" then another dialoge open which have says "camera" or "gallery" etc etc..hope it's work for you.
Try this
By dismissing second dialog you have to call first dialog by yourself and send any result data if you need.