마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

onTouchEvent 메소드의 사소한 질문

0 추천
이벤트로 ACTION_DOWN 이나 ACTION_MOVE를 자주 쓰게 되는데

이 메소드의 리턴 방식에 따라서 작동이 되는게 있고 안 되는게 있더라고요

return false; 일때는 ACTION_DOWN 은 작동이 되지만 ACTION_MOVE는 작동이 안 되더라고요

return true; 로 바꿔주니 그제서야 작동이 되었는데요

이 메소드는 매번 return true; 로 해줘야 잘 작동하게 되는건가요?

아니면 return true; 도 작동이 안 되는게 있나요?

그동안 눈치채지 못했던 부분이네요

이번에 잘 알아가고 싶습니다
Jongbin707 (120 포인트) 님이 2015년 3월 2일 질문

2개의 답변

0 추천
For OnInterceptTouchEvent():

2) The down event will be handled either by a child of this view group, or given to your own 
onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, 
so you will continue to see the rest of the gesture (instead of looking for a parent view to 
handle it). Also, by returning true from onTouchEvent(), you will not receive any following 
events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like 
normal.
Djleeee (13,180 포인트) 님이 2015년 3월 3일 답변
0 추천
return true; 이벤트가 잘 처리되었으므로 윗단(시스템)으로 넘기지않음

return false; 이벤트를 처리하든말든 윗단으로 넘겨주셔요...
nicehee (73,100 포인트) 님이 2015년 3월 3일 답변
...