Search code examples
androidtouch-event

What should I override onTouchEvent() or onTouchListener() in Android?


Hi in game programming in android where I draw things to the screen in a different thread using a SurfaceView, in order to receive touch events, should I override the onTouchEvent() method, or onTouchListener() from the View.onTouchListener interface?


Solution

  • Well, it doesn't really matter, as both can do the same job. However overriding onTouchEvent results in more concise code, as you don't have to supply an implementation of a listener.