如何在Android中取消ProgressDialog

如何在Android中取消ProgressDialog,android,progressdialog,Android,Progressdialog,如何在android中取消ProgressDialog,加载时我不想中止ProgressDialog SingupBar = new ProgressDialog(this); SingupBar.setMessage("Chargement..."); SingupBar.setIndeterminate(false); SingupBar.show(); ....... SingupBar.hi

如何在android中取消
ProgressDialog
,加载时我不想中止
ProgressDialog

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

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

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

使用
对话框。setCancelable(false)


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

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

setCancelable属性会执行此操作

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

将其设置为false。

@Yasser B.

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

 SingupBar.setCanceledOnTouchOutside(false);
最后,

SingupBar = new ProgressDialog(this);
SingupBar.setMessage("Chargement...");
SingupBar.setIndeterminate(false);
SingupBar.setCancelable(false);
SingupBar.setCanceledOnTouchOutside(false);
欲了解更多信息,请访问


很难理解你的意思,但是你可以设置.setCancelable(true);可能重复的
SingupBar = new ProgressDialog(this);
SingupBar.setMessage("Chargement...");
SingupBar.setIndeterminate(false);
SingupBar.setCancelable(false);
SingupBar.setCanceledOnTouchOutside(false);