Search code examples
androidandroid-edittextgifandroid-inputtype

How to disable GIFs from being entered in Android EditText?


How can I shut down the possibility for the user to insert GIFs in EditText? I tried to switch different inputTypes, but I couldn't find a solution.


Solution

  • That's my solution for the question. Adding a textwatcher and checking if it contains the beginning of the URL. The user can still see the GIFs, but cannot enter one. Maybe it's not the best solution, but it works.

    @Override
            public void afterTextChanged(View view, Editable s) {
                if (view.getId() == R.id.edittext) {
                    if(s.contains("https://"){
                        editText.setText("");
                    }
                }
            }