2

How to make the ProgressDialog uncanceled in android, when loading I don't want to have the ability to abort the ProgressDialog

        SingupBar = new ProgressDialog(this);
        SingupBar.setMessage("Chargement...");
        SingupBar.setIndeterminate(false);

        SingupBar.show();
        .......
        SingupBar.hide();

and is this the best way to use it ?

N J
  • 27,217
  • 13
  • 76
  • 96
Stranger B.
  • 9,004
  • 21
  • 71
  • 108
  • hard to catch what do you mean, but you can set .setCancelable(true); – Viktor Yakunin Aug 25 '15 at 16:56
  • possible duplicate of [How can I make a ProgressDialog be cancelable by the back button but not by a screen tap?](http://stackoverflow.com/questions/8100223/how-can-i-make-a-progressdialog-be-cancelable-by-the-back-button-but-not-by-a-sc) – Viktor Yakunin Aug 25 '15 at 16:57

4 Answers4

2

Use dialog.setCancelable(false);

    SingupBar = new ProgressDialog(this);
    SingupBar.setMessage("Chargement...");
    SingupBar.setIndeterminate(false);
    SingupBar.setCancelable(false);
N J
  • 27,217
  • 13
  • 76
  • 96
2

@Yasser B.

You can and to prevent dismiss dialog box on outside touch use this

 SingupBar.setCanceledOnTouchOutside(false);

Finally,

SingupBar = new ProgressDialog(this);
SingupBar.setMessage("Chargement...");
SingupBar.setIndeterminate(false);
SingupBar.setCancelable(false);
SingupBar.setCanceledOnTouchOutside(false);

For more info you can visit

http://developer.android.com/reference/android/app/Dialog.html#setCancelable(boolean)

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

Create a custom dialog with progress bar in it use this....

Dialog d = new Dialog(getBaseContext());
d.setCancelable(false);
Iamat8
  • 3,888
  • 9
  • 25
  • 35
0

The setCancelable property does it

     ProgressDialog   progressDialog = new ProgressDialog(this);
     progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
     progressDialog.setMessage("Loading...please wait");
     progressDialog.setCancelable(false);
     progressDialog.show();

set it to false.

Ibukun Muyide
  • 1,294
  • 1
  • 15
  • 23