android密码显示和隐藏

if (showPwd){
                    //设置EditText文本为可见的
                    password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                    showPassword.setImageResource(R.drawable.ic_show_pwd);
                    showPwd = false;
                }else {
                    //设置EditText文本为隐藏的
                    password.setTransformationMethod(PasswordTransformationMethod.getInstance());
                    showPassword.setImageResource(R.drawable.ic_hide_pwd);
                    showPwd = true;
                }
原文地址:https://www.cnblogs.com/thankyouGod/p/6427090.html