How to add a gesture detector to a view in Android : <p>I was struggling with adding a gesture detector to a subview in my project. Do I override the parent's <code>onTouchEvent</code> or the child's <code>onTouchEvent</code>? Do I make an <code>OnTouchListener</code> and add the gesture detector there? The <a href="https://developer.android.com/training/gestures/detector.html" rel="noreferrer">documentation</a> shows an example for how to add a gesture detector to the activity itself but it is not clear how to add it to a view. The same process could be used if subclassing a view (example <a href="https://stackoverflow.com/a/20112261/3681880">here</a>), but I want to add the gesture without subclassing anything.</p>

<p><a href="https://stackoverflow.com/questions/4098198/adding-fling-gesture-to-an-image-view-android">This</a> is the closest other question I could find but it is specific to a fling gesture on an <code>ImageView</code>, not to the general case of any <code>View</code>. Also there is some disagreement in those answers about when to return <code>true</code> or <code>false</code>. </p>

<p>To help myself understand how it works, I made a stand alone project. My answer is below.</p>
