解释 ClickableViewAccessibility

Explain ClickableViewAccessibility

关于 the SO swipe code,Android lint 给出了警告

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

description of the warning 中,它说:

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.

你好"handle accessibility actions properly"吗?

出现警告是因为代码侦听 onTouchEvent(请参阅 docs, point 3). There is a pointer to a solution for a click event,但这并未解决是否需要处理滑动。

解决方法是使用触发与滑动事件相同的动作的按钮。然后,使用 @SuppressWarnings.