java – Custom view 'ImageButton' has setOnTouchListener called on it but does not override performClick-ThrowExceptions

Exception or error:

Well, I know there are some questions regarding this warning, but i still cannot figure out how to get rid of this.
I don’t want to implement the OnTouchListener interface on class level, because there are many buttons and i prefer to keep every piece of code on his own “space”.
I added performClick() after ACTION_UP case but the warning still persist.

enter image description here

Thank you

send.setOnTouchListener(new View.OnTouchListener() {
                public boolean onTouch(View view, MotionEvent motionEvent) {
                    switch (motionEvent.getAction()){
                        case MotionEvent.ACTION_UP:
                    return true;
How to solve:

Your code is OK, if you are sure that your code works like you want, you can just disable this kind of warnings in: File -> Settings -> Editor -> Inspections -> Android -> Lint -> Accessibility -> Accessibility in Custom Views


Basically it suggests that you should subclass ImageButton and override its performClick() method but it’s not worth the hassle just suppress this warning using @SuppressLint("ClickableViewAccessibility") in your method or just disable this warning like I did.


Change your this line of code

View.performClick ();


send.performClick ();

And add this override method at the end of you activity.

public boolean performClick() {
// do what you want
return true;

Hope that helps

Leave a Reply

Your email address will not be published. Required fields are marked *