禁止从用户操作的整个活动

编程入门 行业动态 更新时间:2024-10-11 01:18:36
本文介绍了禁止从用户操作的整个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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.

更多推荐

禁止从用户操作的整个活动

本文发布于:2023-11-09 07:44:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!