Posts

Showing posts with the label Android - Gestures Tutorial

Android - Gestures Tutorial

Image
Android provides special types of touch screen events such as pinch , double tap, scrolls , long presses and flinch. These are all known as gestures. Android provides GestureDetector class to receive motion events and tell us that these events correspond to gestures or not. To use it , you need to create an object of GestureDetector and then extend another class with GestureDetector.SimpleOnGestureListener  to act as a listener and override some methods. Its syntax is given below − GestureDetector myG ; myG = new GestureDetector ( this , new Gesture ()); class Gesture extends GestureDetector . SimpleOnGestureListener { public boolean onSingleTapUp ( MotionEvent ev ) { } public void onLongPress ( MotionEvent ev ) { } public boolean onScroll ( MotionEvent e1 , MotionEvent e2 , float distanceX , float distanceY ) { } public boolean onFling ( MotionEvent e1 , MotionEvent e2 , float velocityX , ...