android怎样用代码改变EditText的passWord属性的值?
mCheckBoxView = (CheckBox) findViewById(R.id.settings_synch_delet);
mEditTextView = (EditText) findViewById(R.id.account_password);
mCheckBoxView.setOnCheckedChangeListener(checkBox_Listener);
private CheckBox.OnCheckedChangeListener checkBox_Listener = new CheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if(mCheckBoxView.isChecked()){
//文本正常显示
mEditTextView.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
Editable etable = mEditTextView.getText();
Selection.setSelection(etable, etable.length());
}else{
//文本以密码形式显示
mEditTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
//下面两行代码实现: 输入框光标一直在输入文本后面
Editable etable = mEditTextView.getText();
Selection.setSelection(etable, etable.length());
}
}
};
//文本以密码形式显示
mEditTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
//下面两行代码实现: 输入框光标一直在输入文本后面
Editable etable = mEditTextView.getText();
Selection.setSelection(etable, etable.length());