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.
Thank you
send.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_UP:
view.performClick();
break;
default:
break;
}
return true;
}
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With