Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain ClickableViewAccessibility

Concerning the SO swipe code, Android lint gave the warning

OnSwipeTouchListener#onTouch should call View#performClick when a click is detected [ClickableViewAccessibility]

In the description of the warning, it says:

If a View that overrides onTouchEvent or uses an OnTouchListener does not also implement performClick and call it when clicks are detected, the View may not handle accessibility actions properly. Logic handling the click actions should ideally be placed in View#performClick as some accessibility services invoke performClick when a click action should occur.

How do you "handle accessibility actions properly"?

like image 601
serv-inc Avatar asked Jul 10 '15 15:07

serv-inc


Video Answer


1 Answers

The warning arises because the code listens for onTouchEvent (see docs, point 3). There is a pointer to a solution for a click event, but that does not address whether a swipe needs to be handled or not.

A workaround would be to use buttons that trigger the same action as the swipe event. Then, to use @SuppressWarnings.

like image 198
serv-inc Avatar answered Nov 04 '22 01:11

serv-inc