// 设置密码隐藏或显示,并且将光标定位到文本最后
showPwd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
pwdText.setTransformationMethod(HideReturnsTransformationMethod
.getInstance());
} else {
pwdText.setTransformationMethod(PasswordTransformationMethod
.getInstance());
}
CharSequence pwdStr = pwdText.getText().toString()
.trim();
pwdText.setSelection(pwdStr.length());
}
});