创建一个类 extends ReplacementTransformationMethod 如下:
import android.text.method.ReplacementTransformationMethod;
public class AllCapTransformationMethod 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;
}
}
大小写转换使用方法
et_fdj_num= (EditText) view.findViewById(R.id.et_fdj_num);et_fdj_num.setTransformationMethod(new AllCapTransformationMethod());