Android: how to disable controls during progress bar is active

后端 未结 4 2326
逝去的感伤
逝去的感伤 2021-02-19 08:47

I show my infinte progress bar in the action bar \"as usual\":

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
...
setProgressBarIndeterminateVisibi         


        
相关标签:
4条回答
  • 2021-02-19 09:23

    try putting progressDialog.setcancelable(false);

    0 讨论(0)
  • 2021-02-19 09:26

    What you can do is to bring up an invisible dialog and prevent it from being cancellable. It will show whatever is underneath it but disable all underlying user interaction. Then once you are done with your business you simply dismiss it and go on with your life:

    Dialog mOverlayDialog = new Dialog(mContext, android.R.style.Theme_Panel); //display an invisible overlay dialog to prevent user interaction and pressing back
    mOverlayDialog.setCancelable(false);
    mOverlayDialog.show();  
    
    0 讨论(0)
  • 2021-02-19 09:29

    You are trying to set just the Property of Activity. Instead Bring up a dialog using ProgressDialog, so that Ui will not be accessible

    ProgressDialog dialog = ProgressDialog.show(this, "", "Please wait...", true);
    

    Edit: If you do not want to use ProgressDialog, get the Root Layout and call

    layout.setEnabled(false)
    
    0 讨论(0)
  • 2021-02-19 09:41

    in case, if somebody else faced the same problem,

    to disable editing the text use: EditText.setFocusable(false);

    to enable editing: EditText.setFocusableInTouchMode(true);

    0 讨论(0)
提交回复
热议问题