源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android开发笔记之:如何屏蔽Button setClickable与setEnabled

  • 时间:2021-04-23 22:20 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android开发笔记之:如何屏蔽Button setClickable与setEnabled
今天想让按键暂时无效,满足一定条件下才可以被用户按到。最初以为是setClickable,谁知搞错了。 请看手册:
[u]复制代码[/u] 代码如下:
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 clickable True if the node is clickable. Throws IllegalStateException If called from an AccessibilityService. public void setContentDescription (CharSequence contentDescr
这个函数的意思是让按键按一下。比如弄一个定时器,然后在手机上模拟,多长时间到了让按键自己按一下,而不是手动去按,可以用这个函数。
[u]复制代码[/u] 代码如下:
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 enabled True if the node is enabled. Throws IllegalStateException If called from an AccessibilityService.
这个函数才是真正的,让一个按键可以被用户按,或者不可按。如果设为false,按键则会变成灰色的,按上去也没反应。当设为true后,才会正常使用。这正是我找的函数。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部