zoukankan      html  css  js  c++  java
  • 密码框显示和隐藏

    1. import android.app.Activity;    
    2. import android.graphics.Rect;    
    3. import android.os.Bundle;    
    4. import android.text.method.HideReturnsTransformationMethod;    
    5. import android.text.method.PasswordTransformationMethod;    
    6. import android.text.method.TransformationMethod;    
    7. import android.view.View;    
    8. import android.widget.CheckBox;    
    9. import android.widget.CompoundButton;    
    10. import android.widget.CompoundButton.OnCheckedChangeListener;    
    11. import android.widget.EditText;    
    12.     
    13.     
    14. public class PasswordIsShowTestActivity extends Activity {    
    15.         
    16.     private EditText username;    
    17.     private EditText password;    
    18.     private CheckBox cbBox ;    
    19.         
    20.     @Override    
    21.     public void onCreate(Bundle savedInstanceState) {    
    22.         super.onCreate(savedInstanceState);    
    23.         setContentView(R.layout.main);    
    24.             
    25.         username = (EditText)findViewById(R.id.editText1);    
    26.         password = (EditText)findViewById(R.id.editText2);    
    27.         cbBox = (CheckBox)findViewById(R.id.checkBox1);    
    28.         cbBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {    
    29.                 
    30.             @Override    
    31.             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {    
    32.                 if(cbBox.isChecked()){    
    33.                                      password.setTransformationMethod(    
    34.                             HideReturnsTransformationMethod.getInstance());    
    35.                 }else{    
    36.                                password.setTransformationMethod(    
    37.                             PasswordTransformationMethod.getInstance());    
    38.                 }    
    39.             }    
    40.         });    
    41.     }    
    42. }   
  • 相关阅读:
    mysql 数据库初识
    Python3进行RSA2加密、解密、签名
    jenkins一次构建两次触发job问题
    docker 端口被占用问题解决
    jacoco 的使用及与jenkins的集成
    python 学习笔记二 (列表推导式)
    python 学习笔记一 (数据结构和算法)
    请求超时及重试的设置
    python 中 str与bytes的转换
    JS模块化
  • 原文地址:https://www.cnblogs.com/zhiqiangsimida/p/2774701.html
Copyright © 2011-2022 走看看