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());
                            }
                        }
                    });
     
        } 
     
  • 相关阅读:
    BUG漏测的原因总结,以及如何处理
    费用流
    拉格朗日插值
    数论问题整理
    计数问题
    POJ 1741 Tree
    bzoj 2820: YY的GCD
    luogu P3690 【模板】Link Cut Tree (动态树)
    bzoj 1036: [ZJOI2008]树的统计Count
    bzoj 3282: Tree
  • 原文地址:https://www.cnblogs.com/zyh-blog/p/3324486.html
Copyright © 2011-2022 走看看