Android 编辑文本 : How to avoid user enter smileys?

标签 android android-edittext android-keypad

我想避免用户用键盘将笑脸放入 EditText 中。可能吗?

enter image description here

最佳答案

编辑来自 here 的答案.

这将只允许在 EditText 中输入 ASCII 字符。

edittext.setFilters(new InputFilter[] {
 new InputFilter() {
    public CharSequence filter(CharSequence src, int start,
            int end, Spanned dst, int dstart, int dend) {
        if(src.equals("")){ // for backspace
            return src;
        }
        if(src.toString().matches("[\\x00-\\x7F]+")){
            return src;
        }
        return "";
    }
 }
});

关于Android 编辑文本 : How to avoid user enter smileys?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24447928/

相关文章:

android - Firebase 动态链接在特定情况下未启动我的应用程序

android - EditText - 清除文本时光标将开始显示每个字母

javascript - 如何通过Web应用程序(ReactJS)检测Android设备虚拟键盘中的空格键

android - NullPointerException在TextInputLayout上

android - 如何开始使用 Android 的通话费用应用程序?

android - Galaxy Tab 上的 EditText 单行问题

android - 软键盘弹出并缓慢隐藏在 fragment 中,使打字缓慢

java - 如何像软键盘一样将 PopupWindow 设置在根布局的底部?

android - "adb pull"抛出 "does not exist"

android - 如何在软键盘中显示空格键并在用户单击空格键时执行某些操作