android EditText完美解决禁止输入法表情
给EditText设置过滤器。
·
给EditText设置过滤器
InputFilter[] emojiFilters = {emojiFilter};
sosMsg.setFilters(emojiFilters);
InputFilter emojiFilter = new InputFilter() {
Pattern emoji = Pattern.compile("[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
Matcher emojiMatcher = emoji.matcher(source);
if (emojiMatcher.find()) {
Toast.makeText(getActivity(),"不支持输入表情", Toast.LENGTH_SHORT).show();
return "";
}
return null;
}
};
更多推荐
已为社区贡献9条内容
所有评论(0)