Skip to content

Instantly share code, notes, and snippets.

@tuchangwei
Created June 22, 2015 02:13
Show Gist options
  • Save tuchangwei/c31064c3359daa689008 to your computer and use it in GitHub Desktop.
Save tuchangwei/c31064c3359daa689008 to your computer and use it in GitHub Desktop.
// First create the GestureListener that will include all our callbacks.
// Then create the GestureDetector, which takes that listener as an argument.
GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener();
final GestureDetector gd = new GestureDetector(getActivity(), gestureListener);
/* For the view where gestures will occur, create an onTouchListener that sends
* all motion events to the gesture detector. When the gesture detector
* actually detects an event, it will use the callbacks you created in the
* SimpleOnGestureListener to alert your application.
*/
gestureView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment