sketchub icon

Edit text reject emojis

Omnicron_Hydra
3 Likes
0 Comments
36 Downloads

What's new

Make your edittext reject emojis input

Screenshots

About

Here's the source code - ONCREATE of activity

EditText editText = findViewById(R.id.editText);

editText.setFilters(new InputFilter[] { new 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) { Toast.makeText(getApplicationContext(), "Emojis are not allowed", Toast.LENGTH_SHORT).show(); return ""; } } return null; } } });

©2024 Sketchub | User Policy