方案一阱表,親測無效人柿!
// editText.setInputType(InputType.TYPE_CLASS_NUMBER);
etCode.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
editText.setKeyListener(DigitsKeyListener.getInstance("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"));
測試發(fā)現(xiàn)是顯示數(shù)字鍵盤, 親測不行。
方案二君仆,親測有效翩概!
etCode.setKeyListener(new DigitsKeyListener() {
@Override
public int getInputType() {
return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
}
@NonNull
@Override
protected char[] getAcceptedChars() {
return "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
}
});