在EditText里输入小写字母时,将小写字母转化为大写显示

1、新建类继承ReplacementTransformationMethod 方法

public class test extends ReplacementTransformationMethod {
@Override
protected char[] getOriginal() {
char[] aa = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
return aa;
}

@Override
protected char[] getReplacement() {
char[] cc = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
return cc;
}
}
2、在java中设置edittext属性
edittext.
setTransformationMethod(new test());

原文地址:https://www.cnblogs.com/judes/p/5789943.html