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 to declare the interfaces and to extract and store a reference to the TextView component in the user interface:
package com.ebookfrenzy.commongestures;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity
implements...