28.3 Implementing the Listener Class
As previously outlined, it is necessary to create a class that implements the GestureDetector.OnGestureListener interface and, if double tap detection is required, the GestureDetector.OnDoubleTapListener interface. While this can be an entirely new class, it is also perfectly valid to implement this within the current activity class. For the purposes of this example, therefore, we will modify the MainActivity class to implement these listener interfaces. Edit the MainActivity.java file so that it reads as follows:
package com.ebookfrenzy.commongestures;
import android.view.GestureDetector;
.
.
public class MainActivity extends AppCompatActivity
implements GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener
{
.
.
}
Declaring that the class implements the listener interfaces mandates that...