Show One Progress Dialog Only At A Time In Android?
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
Solution 1:
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.
private void popupPhotoSelector(){
Utilities.alert_video("", null,
// Utilities.alert("", null,
new AlertDialogActionSettings("Take Picture", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
overwritePhoto = true;
takePicture();
}
}),
new AlertDialogActionSettings("Gallery", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
overwritePhoto = true;
openGallery();
}
}),
///////////////////// Add Video //////////////////////////////
new AlertDialogActionSettings("Add Video", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Intent intent = new Intent(getBaseContext(), Main_Vevue_Activity.class);
//startActivity(intent);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("MLI");
// set dialog message
alertDialogBuilder
.setMessage("Take Video From!")
.setCancelable(true)
.setPositiveButton("Camera",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
overwritePhoto = true;
takeVideo();
}
})
.setNegativeButton("Gallery",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
overwritePhoto = true;
openGalleryForVideo();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
}),
///////////////////// Add Video End //////////////////////////////
null, false
);
}
Solution 2:
By dismissing second dialog you have to call first dialog by yourself and send any result data if you need.
Solution 3:
Try this
publicvoidshowProgressDialog(final Context ctx, boolean isCancelable) {
ProgressDialogdialog=newProgressDialog(ctx);
dialog.setCancelable(false);
dialog.setTitle("Title dialog");
dialog.setMessage("downloading");
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setProgress(0);
if(isCancelable)
{
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "cancel", newDialogInterface.OnClickListener() {
@OverridepublicvoidonClick(DialogInterface dialog, int which) {
showDialog2(ctx);
}
});
}
dialog.show();
}
privatevoidshowDialog2(final Context ctx) {
AlertDialog.Builderbuilder=newBuilder(ctx);
builder.setMessage("cancel");
builder.setTitle("dialog title");
builder.setPositiveButton("cancel", newOnClickListener() {
@OverridepublicvoidonClick(DialogInterface dialog, int which) {
showProgressDialog(ctx, false);
dialog.dismiss();
}
});
builder.setNegativeButton("confirm", null);
builder.create().show();
}
Post a Comment for "Show One Progress Dialog Only At A Time In Android?"