mEtWifiWlanHotspotInfo.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20), new InputFilter() { Pattern isAvalidWord = Pattern.compile("[[A-Z]|[a-z]|[0-9]]*"); @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { Matcher matcher = isAvalidWord.matcher(source); StringBuilder matcherString = new StringBuilder(); while (matcher .find()) { matcherString.append(matcher.group(0)); } return matcherString; } }});
// 同时实现限制EditText只能输入20个字符,且只能输入大小写字母及数字(挑出符合正则表达式的字符)