【问题标题】:How to make a ProgressDialog uncanceled in Android如何在Android中取消ProgressDialog
【发布时间】:2015-08-25 16:54:36
【问题描述】:

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

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

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

这是最好的使用方式吗?

【问题讨论】:

标签: android progressdialog


【解决方案1】:

使用dialog.setCancelable(false);

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

【讨论】:

    【解决方案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)

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        【解决方案4】:

        setCancelable 属性可以做到这一点

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

        将其设置为 false。

        【讨论】:

          猜你喜欢
          • 2013-02-23
          • 1970-01-01
          • 2014-05-29
          • 1970-01-01
          • 2016-07-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多