主要要使用一个正则过滤即可实现:
String regular = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; mXEditText.setKeyListener(new DigitsKeyListener() { @Override public int getInputType() { return InputType.TYPE_TEXT_VARIATION_PASSWORD; } @Override protected char[] getAcceptedChars() { char[] ac = regular.toCharArray(); return ac; } });