【发布时间】:2016-04-18 11:27:06
【问题描述】:
我想在选中开关时将编辑文本的输入类型更改为可见。
Switch a =(Switch) findViewById(R.id.switch1);
a.setText("visible");
a.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
EditText pass = (EditText) findViewById(R.id.pass);
pass.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}else{
EditText pass = (EditText) findViewById(R.id.pass);
pass.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
}
});
当我打开开关并使密码可见时它可以工作,但当我关闭它时它仍然可见并且不会改变。
【问题讨论】:
标签: java android android-edittext android-appwidget android-inputtype