禁止从用户操作的整个活动 [英] Disable a whole activity from user action

查看:192
本文介绍了禁止从用户操作的整个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单的方法来禁用用户与活动交互。 当有运行一个动作(在标题栏旋转的进度条)做

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.

这篇关于禁止从用户操作的整个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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