Using gesture overlay view in android

So, I'm trying to use the overlay view of gestures in android to do swipe. So when the user โ€œchecksโ€, he executes a certain code, and when they scroll to the right, he executes another code. I tried declaring gestureoverlay as follows:

GestureOverlayView gest = (GestureOverlayView) findViewById(R.id.hatgest); 

But then I donโ€™t know where to go from there, and I canโ€™t find anything useful in the developer guide or on the Internet. For a button, I would usually use "onclicklistener", how would I do this with overlay gestures? Does anyone have code examples that I can use? Thanks

+8
android
source share
2 answers

First, make individual gestures from the gesture maker. The gesture builder application is included in sdk. Place the file created from the gesture builder application in the raw folder of the application that you intend to use in these gestures. You can also get help documentation.

  public class YourClass extends Activity implements OnGesturePerformedListener { private GestureLibrary mLibrary; mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures); if (!mLibrary.load()) { finish(); } GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures); gestures.addOnGesturePerformedListener(this); public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { ArrayList < Prediction > predictions = mLibrary.recognize(gesture); Log.v("performed", "performed"); // We want at least one prediction if (predictions.size() > 0) { Prediction prediction = predictions.get(0); // We want at least some confidence in the result if (prediction.score > 1.0) { if (prediction.name.equalsIgnorecase("right")) { //do you thing here// } } } } } 
+11
source share

Obviously, GestureOverlayViews can have multiple onGestureListeners.

Check the addOnGestureListener () and addOnGesturePerformedListener () method.

-one
source share

All Articles