Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to avoid adding emoticons in android edittext

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 5.08k
    Comment on it

    If you don't want to allow users to add emoji in edittext then below few lines will be helpfull for you. This method will return blank string while typing any similies/emoji in your editext.

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

    call this EMOJI_FILTER in your onCreate() method with edittext whome you have to avoid typing emoticons.

            yourEdittext.setFilters(new InputFilter[]{AppUtility.EMOJI_FILTER});

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: