Search code examples
androidontouchlistenertouch-event

onTouchevent() vs onTouch()


After many experiments with onTouchEvent and onTouch, I found that onTouch works everywhere you want (whether it is in activity or view) as long as you have declared the interface and put the Listener right! On the other hand, onTouchEvent only works inside a View! Is my assumption correct? Is this the real difference?


Solution

  • Yes you are correct - onTouch() is used by users of the View to get touch events while onTouchEvent() is used by derived classes of the View to get touch events.