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
  • 相关阅读:
    谜之This
    JS 面向对象 ~ 继承的7种方式
    JS 面向对象 ~ 创建对象的 9 种方式
    JS 原型与原型链
    ES6 Promise 详解
    Vue diff 算法
    Vue Router 路由实现原理
    Vue Keep-alive 原理
    Vue 响应式原理
    JS 有趣的JS
  • 原文地址:https://www.cnblogs.com/GentlemanMod/p/3277433.html
Copyright © 2011-2022 走看看