Android的:如何禁用控制在进度栏活动
我展示我的操作栏中的一切照旧infinte进度条:
I show my infinte progress bar in the action bar "as usual":
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
...
setProgressBarIndeterminateVisibility(true);
...
setProgressBarIndeterminateVisibility(false);
和真正的工作是在后台线程进行(AsyncTask的)
and the real work is done in a background thread (AsyncTask)
的问题:在用户界面上的所有控制有效,所以用户可以继续修改的基础数据之前,持久处理结束
The problem: all controls on the UI are enabled, so the user can continue to modify the underlying data before the long lasting process is finished.
只要禁用所有的控制是不可能的。
Simply disabling all controls is not possible because when disabling an EditText, also the keyboard is closed automatically by Android.
任何想法如何prevent用户输入在后台工作?
Any ideas how to prevent user input during the background work?
谢谢
克里斯
你可以做的是从被撤销弹出一个无形的对话和prevent它。它会显示什么是它的下面,但禁用所有潜在的用户交互。然后,一旦你与你的业务做的,你轻易否定它,并继续你的生活:
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();