How to disable GIFs from being entered in Android EditText?

1k views Asked by At

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.

1

There are 1 answers

2
Miki On BEST ANSWER

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("");
                }
            }
        }