您的位置:首页 > 移动开发 > Android开发

Android输入框切换密码显示与隐藏

2015-01-16 16:53 218 查看
pwd = (EditText) findViewById(R.id.e1);

Button btn = (Button) findViewById(R.id.b1);

btn.setOnClickListener(new OnClickListener() {



@Override

public void onClick(View v) {

if(pwd.getInputType()==128){


pwd.setInputType(129);

}else{


pwd.setInputType(128);

}

pwd.postInvalidate();

Spannable text=pwd.getText();

Selection.setSelection(text, text.length());

}

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: