Created
June 22, 2015 02:13
-
-
Save tuchangwei/c31064c3359daa689008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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