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; }