뷰를 하나 만들고 터치 리스너를 추가했습니다. (println은 직접 만든 메소드입니다)

그런데 귀찮게시리 안드로이드 스튜디오의 Lint Warning이 나옵니다.

onTouch lambda should call View#performClick when a click is detected

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.

Issue id: ClickableViewAccessibility

읽어보면 onTouchEvent를 오버라이드 하거나 OnTouchListener를 사용할 때 performClick을 사용하도록 해야 접근성(Accessibility)이 높아진다는 것입니다. 클릭했을 때 이벤트는 performClick을 이용해 다루는 것이 이상적이다 라는 내용이네요.

 

해결방법 1. performClick을 사용한다

onTouch 람다 안에서 v.performClick()을 호출해줍니다.

꼭 ACTION_UP 부분에서 처리할 필요는 없습니다. 이건 프로그램 로직에 따라 알아서 구현하시면 되겠습니다.

 

해결방법 2. @SuppressLint("ClickableViewAccessibility")

로직이 performClick을 쓰기 애매한 경우는 @SuppressLint("ClickableViewAccessibility") 어노테이션을 추가해 Lint의 Warning을 무시할 수 있습니다.

 

Feedback

???: "전 이거 이상하다고 생각하는데요?"

그렇다면 Android Lint에 False Positive 또는 Unclear Message 피드백을 날려 주시기 바랍니다.

반응형