展会信息港展会大全

Android开发 屏蔽Button setClickable和setEnabled
来源:互联网   发布日期:2015-12-07 15:32:30   浏览:1110次  

导读:今天想让按键暂时无效,满足一定条件下才可以被用户按到。最初以为是setClickable,谁知搞错了。请看手册:[java]瀀甀戀氀椀挀 void setClickable (bool...

今天想让按键暂时无效,满足一定条件下才可以被用户按到。最初以为是setClickable,谁知搞错了。

请看手册:

[java]

public void setClickable (boolean clickable)

Since: API Level 14

Sets whether this node is clickable.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters

clickableTrue if the node is clickable.

Throws

IllegalStateExceptionIf called from an AccessibilityService.

public void setContentDescription (CharSequence contentDescr

这个函数的意思是让按键按一下。比如弄一个定时器,然后在手机上模拟,多长时间到了让按键自己按一下,而不是手动去按,可以用这个函数。

[java]

public void setEnabled (boolean enabled)

Since: API Level 14

Sets whether this node is enabled.

Note: Cannot be called from an AccessibilityService. This class is made immutable before being delivered to an AccessibilityService.

Parameters www.2cto.com

enabled True if the node is enabled.

Throws

IllegalStateExceptionIf called from an AccessibilityService.

这个函数才是真正的,让一个按键可以被用户按,或者不可按。如果设为false,按键则会变成灰色的,按上去也没反应。当设为true后,才会正常使用。这正是我找的函数。

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港