How to use gesture detector in Fragment class
<p>I have class (MainActivity.java) with extends Activity, in the inside i declare Fragment class (FragmentShow.java) . I tried use GestureDetector in Fragment class, but this gesture not working, if I use GestureDetector in Activity class is working.
The question is how to use GestureDetector in fragment class?</p>

<p>Thanks.</p>

<pre><code>public boolean onTouchEvent(MotionEvent event) {
    this.gestureDetectorCompat.onTouchEvent(event);
    return super.getActivity().onTouchEvent(event);
}

public boolean dispatchTouchEvent(MotionEvent ev) {
    // TODO Auto-generated method stub
    // return super.dispatchTouchEvent(ev);
    super.getActivity().dispatchTouchEvent(ev);
    return gestureDetectorCompat.onTouchEvent(ev);
}

public class MyGestureListener extends
        GestureDetector.SimpleOnGestureListener {
    // handle 'swipe left' action only

    @Override
    public boolean onFling(MotionEvent event1, MotionEvent event2,
            float velocityX, float velocityY) {

        if (event2.getX() &lt; event1.getX()) {
            Utils.log("Swipe left - startActivity()");

        } else {
            Utils.log("Swipe Right - startActivity()");
        }

        return true;
    }
}
</code></pre>

<p>This I call Fragment from MainActivity</p>

<pre><code>FragmentDashboard hello = new FragmentDashboard();
        FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
            .replace(R.id.fragment_container, hello)
                .commit(); 
</code></pre>