如何在Android EditText中屏蔽Mobile Starting数字。
答案 0 :(得分:2)
制作一个类似这样的课程
public class ChangeTransformationMethod 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) {
if(index <=5)
return 'N';
else
return mSource.charAt(index);
}
public int length() {
return mSource.length();
}
public CharSequence subSequence(int start, int end) {
return mSource.subSequence(start, end);
}
}
}
然后在你的EditText上设置它:
editText.setTransformationMethod(new ChangeTransformationMethod());