0

I am trying create an OnTouchListener to my editText ("search").

I took the code from post : Click listener for drawableleft in EditText in Android?

(Along with other posts) I am getting an error saying

Custom view EditText has set OnTouchListener called on it but does not override PerformClick

Not quite sure where to go from here, as there is not much written about this that I can find. Thanks from your help!

search.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                final int DRAWABLE_LEFT = 0;

                if(event.getX() <= (search.getCompoundDrawables()[DRAWABLE_LEFT].getBounds().width()))
                {
                    // your action here
                    return true;
                }
                return false;
            }
        });

Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Matthew Mitchell
  • 514
  • 4
  • 14

1 Answers1

0

You can suppress the error by using @SuppressLint("ClickableViewAccessibility")

Check out this question for more information on your error.

Douglas Hosea
  • 1,002
  • 13
  • 30
  • Thank you! Problem now is I have drawablePadding set to 20dp so if i click on the drawable in the EditText the keyboard pops up instead of handling the onTouch for the drawable... – Matthew Mitchell Oct 13 '18 at 09:17