Handle Touch Events (onTouchEvent)

2 votes · 2 comments

This snippet listens for touch events from the user (touch the screen, move, leave the screen). More infos: http://developer.android.com/guide/topics/ui/ui-events.html

raw ·
copy
· download
public boolean onTouchEvent(MotionEvent event) { int eventaction = event.getAction(); switch (eventaction) { case MotionEvent.ACTION_DOWN: // finger touches the screen break; case MotionEvent.ACTION_MOVE: // finger moves on the screen break; case MotionEvent.ACTION_UP: // finger leaves the screen break; } // tell the system that we handled the event and no further processing is required return true; }
Add a comment

2 Comments

good.......and thanks

Reply · Feb. 7, 2013, 12:12 p.m.

simply explained :)

Reply · March 6, 2014, noon