我有一个 EditText,它是一个密码字段。默认情况下,android 有它的 (.) 点,我想用一些图像点替换它。我怎么能这样做任何建议。
问问题
679 次
1 回答
0
您可以尝试PasswordTransformationMethod类检查此链接
public class MyPasswordTransformationMethod 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; // Store char sequence
}
public char charAt(int index) {
return '*'; // This is the important part
}
public int length() {
return mSource.length(); // Return default
}
public CharSequence subSequence(int start, int end) {
return mSource.subSequence(start, end); // Return default
}
}
};
// Call the above class using this:
text.setTransformationMethod(new MyPasswordTransformationMethod());
于 2013-05-20T11:39:11.137 回答