zoukankan      html  css  js  c++  java
  • 005、打钩显示输入密码

    通过CheckBox.setOnCheckedChangeListener()方法来设置EditText显示密码事件
    EditText的setTransformationMethod()方法是用以设置其显示的字符类型。
    HideReturnsTransformationMethod.getInstance():正常显示所输入的密码字符;
    PasswordTransformationMethod.getinstance():隐藏输入的字符,恢复为密码输入状态。 
     
       @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_transformation_method);
            ((CheckBox) findViewById(R.id.cb))
                    .setOnCheckedChangeListener(new OnCheckedChangeListener() {
     
                        @Override
                        public void onCheckedChanged(CompoundButton buttonView,
                                boolean isChecked) {
                            if (isChecked) {
                                ((EditText) findViewById(R.id.et))
                                        .setTransformationMethod(HideReturnsTransformationMethod
                                                .getInstance());
                            } else {
                                ((EditText) findViewById(R.id.et))
                                        .setTransformationMethod(PasswordTransformationMethod
                                                .getInstance());
                            }
                        }
                    });
     
        } 
     
  • 相关阅读:
    beeline链接hive报错
    Java并发之FairSync和NonfairSync
    如何在 Linux 中将文件编码转换为 UTF-8
    Spring Boot运行原理
    jvm垃圾回收
    jvm调试工具
    Nginx相关
    docker 配置jar ,运行
    centos7的一些安装问题
    Docker
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3324486.html
Copyright © 2011-2022 走看看