简体   繁体   English

删除要从 Android 键盘输入的笑脸

[英]Remove Smileys to be entered from Android Keyboard

My EditText我的编辑文本

Where inputType is android:inputType="text|textCapWords"其中 inputType 是android:inputType="text|textCapWords"

Problem is When KeyBoard is Open, I am able to enter the smileys问题是当键盘打开时,我可以输入笑脸

How to disable the smileys from the Android native keyboard?如何从 Android 原生键盘禁用笑脸?

Any help will be appreciated任何帮助将不胜感激

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/nameInputLayout"
                style="@style/textInputLayout"
                android:layout_marginTop="@dimen/_30sdp"
                app:errorEnabled="true"
                app:errorTextAppearance="@style/ErrorText"
                app:hintTextAppearance="@style/HintText">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/edt_user_name"
                    style="@style/editTextInputLayout"
                    android:hint="@string/enter_your_name"
                    android:imeOptions="actionNext"
                    android:inputType="text|textCapWords"
                    app:fontFamily="@font/muli_regular_font" />


</com.google.android.material.textfield.TextInputLayout>

Try Something like this,This has worked for me尝试这样的事情,这对我有用

editText.setFilters(new InputFilter[]{new EmojiExcludeFilter()});
private class EmojiExcludeFilter implements InputFilter {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            for (int i = start; i < end; i++) {
                int type = Character.getType(source.charAt(i));
                if (type == Character.SURROGATE || type == Character.OTHER_SYMBOL) {
                    return "";
                }
            }
            return null;
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM