Android的:如何禁用控制在进度栏活动 [英] Android: how to disable controls during progress bar is active

查看:150
本文介绍了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();  

这篇关于Android的:如何禁用控制在进度栏活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆