如何在Android中使ProgressDialog无法取消

时间:2015-08-25 16:54:36

标签: android progressdialog

如何在Android中加载ProgressDialog无法取消,加载时我不想让中止ProgressDialog

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

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

这是使用它的最佳方式吗?

4 个答案:

答案 0 :(得分:2)

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

{{1}}

答案 1 :(得分:2)

@Yasser B。

您可以并且在外部触摸时防止关闭对话框使用此

 SingupBar.setCanceledOnTouchOutside(false);

最后,

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

有关详细信息,请访问

  

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

答案 2 :(得分:1)

创建一个带有进度条的自定义对话框,使用此....

Dialog d = new Dialog(getBaseContext());
d.setCancelable(false);

答案 3 :(得分:0)

setCancelable属性执行

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

将其设置为false。