将edittext中密码输入框的原点变为*
public void setEditTextPassWordShowStyle(EditText et) {
et.setTransformationMethod(new PasswordCharSequenceStyle());
}
public class PasswordCharSequenceStyle extends PasswordTransformationMethod {
@Override
public CharSequence getTransformation(CharSequence source, View view) {
return new PasswordCharSequence(source);
}
private class PasswordCharSequence implements CharSequence {
private CharSequence mSource;
public PasswordCharSequence(CharSequence source) {
mSource = source;
}
public char charAt(int index) {
return '*';
}
public int length() {
return mSource.length();
}
public CharSequence subSequence(int start, int end) {
return mSource.subSequence(start, end);
}
}
}
网友评论