使Checkbox禁用,不可选
不可选的状态就是那个选项变灰色!比如我们需要让某个选项满足一定条件才能用,那这个时候setEnabled就派上用场了
setEnabled是什么,来看下手册就明白了。
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,那这个Checkbox就是不可选(灰色),点击选项是无效的!设置true就是可选,选项就可以正常使用!
还有个setChecked函数是控制开关的,如果为true则选项是开着,false的话,选项就是关闭!下面是手册
public abstract void setChecked (boolean checked) Added in API level 1 Change the checked state of the view Parameters checked The new checked state
posted on 2013-08-23 14:18 GentlemanMod 阅读(5454) 评论(0) 编辑 收藏 举报