像wifi连接网络的时候有checkbox,显示密码~
在xml 中容易控制inputtype, 在java代码中如下:
CheckBox cboBox=(CheckBox)findViewById(R.id.cbox_show);
cboBox.setChecked(false);
cboBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (isChecked) {
edt_mail_pass.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);//正常显示,密码可见状态
Editable etable = edt_mail_pass.getText();
Selection.setSelection(etable, etable.length());//光标在末尾显示
}else {
edt_mail_pass.setInputType(InputType.TYPE_CLASS_TEXT |InputType.TYPE_TEXT_VARIATION_PASSWORD);//密码形式显示
Editable etable = edt_mail_pass.getText();
Selection.setSelection(etable, etable.length());
}
}
});