Explain ClickableViewAccessibility

serv-inc picture serv-inc · Jul 10, 2015 · Viewed 10.3k times · Source

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"?

Answer

serv-inc picture serv-inc · Jul 19, 2015

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.