Explain ClickableViewAccessibility

萝らか妹 提交于 2019-12-12 11:32:40

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/31344451/explain-clickableviewaccessibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!