android edit box disable emoji and emoji

//Perfectly solve the illegal characters that cannot be entered in the input box

InputFilter inputFilter=new InputFilter() {

       Pattern pattern = Pattern.compile("[^a-zA-Z0-9\\u4E00-\\u9FA5_,.?!:;…~_\\-\"\"/@*+'()<>{}/[/]()<>{}\\[\\]=%&$|\\/♀♂#¥£¢€\"^` ,。?!:;……~“”、“()”、(——)‘’@‘·’&*#《》¥《〈〉》〈$〉[]£[]{}{}¢【】【】%〖〗〖〗/〔〕〔〕\『』『』^「」「」|﹁﹂`.]");
     
        @Override
        public CharSequence filter(CharSequence charSequence, int i, int i1, Spanned spanned, int i2, int i3) {
            Matches matches = pattern.matcher (charSequence);
            if(!matcher.find()){
                return null;
            }else{
                Toast.makeText(MyApplication.context, "Illegal character!", Toast.LENGTH_SHORT).show();
                return "";
            }

        }
    };



//transfer
 EditText et = (EditText) view.findViewById(R.id.et);
       et.setFilters(new InputFilter[]{inputFilter});



Upvote if it helped you


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326005900&siteId=291194637