O'Reilly logo

Android 5 Programming by Example by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Detecting Touchscreen Gestures

Until now, the apps we created have used OnClickListeners to detect user input. However, Android handsets are capable of handling sophisticated touchscreen gestures. These inputs are picked up with an OnTouchListener and then managed with a GestureDetector. These detectors and their own listeners are capable of recognizing several of the simplest and most commonly used gestures, such as long presses, double-taps, and flings. At the heart of all touchscreen events is the MotionEvent class, which handles the individual elements of a gesture, such as when and where a finger is placed or removed from the screen or view. This class provides numerous classes for querying these events and, thus, for constructing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required