有一个简单的方法来禁用用户与活动交互。 当有运行一个动作(在标题栏旋转的进度条)做
Is there a simple way to disable a user interacting with an activity. To be done when there is an action running (and a spinning progress bar in the title bar)
编辑:看来我不太清楚我的意思是说:虽然我已经有一个旋转的进度条,用户仍然能够推进该活动的任何按钮,我想从能够禁用用户这样做,虽然任务运行。我不想逐一但禁用屏幕就每个项目。
As it seems I was not clear enough I meant to say: while I already have a spinning progress bar, the user is still able to push any button on the activity, I want to disable the user from being able to do that while the task is running. I do not want to however disable each item on the screen one by one.
谢谢,杰森
推荐答案为了阻止用户触摸事件,使用:
In order to block user touch events, use:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);要获取触摸事件后面,使用:
To get touch events back, use:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
编辑: 如果你想添加的禁用功能和灰色的显示,你需要在你的XML布局文件中添加填充母线性布局。设置背景为#B0000000和它的可见性来了。比起programicly其可见性设置为可见。
If you want to add a feature of disable and greyed out display, you need to add in your xml layout file a linear layout that fills the parent. Set its background to #B0000000 and its visibilty to Gone. Than programicly set its visibility to Visible.
更多推荐
禁止从用户操作的整个活动
发布评论