1、通过调用<span style="font-family: Arial, Helvetica, sans-serif;">CheckBox的</span><span style="font-family: Arial, Helvetica, sans-serif;">setOnCheckedChangeListener方法</span>
<span style="font-family: Arial, Helvetica, sans-serif;">2、</span><pre name="code" class="java">EditText<pre name="code" class="java">setTransformationMethod 方法,<pre name="code" class="java">显示输入的密码:HideReturnsTransformationMethod.getInstance()
隐藏输入的密码:<span style="font-family: Arial, Helvetica, sans-serif;">PasswordTransformationMethod.getInstance()</span>
</pre><pre name="code" class="java">private void initView() {
ed_pwd=(EditText) findViewById(R.id.pwd_ed);
vb_pwd=(CheckBox) findViewById(R.id.visibility_pwd_cbox);
vb_pwd.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
if(vb_pwd.isChecked()){
ed_pwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}else{
ed_pwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
});
}