zoukankan      html  css  js  c++  java
  • 使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
  • 相关阅读:
    Bash : 冒泡排序
    Azure Load Balancer : 支持 IPv6
    Azure Load Balancer : 简介
    sudo 与输出重定向
    Linux lsof 命令
    Bash : IO 重定向
    LVM : 快照
    2014年全年总结
    使用Kindle4rss推送自己感兴趣的博文
    换SSD硬盘,重装系统,一阵子忙乱
  • 原文地址:https://www.cnblogs.com/GentlemanMod/p/3277433.html
Copyright © 2011-2022 走看看