Reputation: 1636
What Gesture file should be downloaded and paste it in Raw folder under res? How if user's drawn gestures would be recognized from gesture file which has been downloaded. Could anyone tell me this?
If i do compare, i should be able to know about the Gestures and its description in Gesture File which has been downloaded. It will be a easiest way to recognise the gestures (User Drawn) from Gesture library.
Upvotes: 2
Views: 3164
Reputation: 212
in android emulator open gesture builder app then --> click on add gesture --> draw ur gesture there which you want to use for your application. After adding gesture go to your eclipse ide --> open ddms -->open file explorer.
in file explorer there is folder called mnt/sdcard/gestures you find your gesture file. now copy that file to your project in Raw folder where you want to use that gesture action.
after that
private GestureLibrary gestureLib;
private static final int LARGE_MOVE = 20;
private GestureDetector gestureDetector;
make your class implements OnGesturePerformedListener
//put following code inside your on create method
GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
View inflate = getLayoutInflater().inflate(your layout file, null);
gestureOverlayView.addView(inflate);
gestureOverlayView.setGestureColor(Color.TRANSPARENT);
gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT);
gestureOverlayView.setGestureStrokeLengthThreshold(LARGE_MOVE);
gestureOverlayView.setGestureStrokeSquarenessTreshold(1);
gestureOverlayView.addOnGesturePerformedListener(this);
gestureOverlayView.setEventsInterceptionEnabled(true);
try{
gestureDetector = new GestureDetector(your class name.this, new SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,float velocityX, float velocityY){
if (e1.getX() - e2.getX() > LARGE_MOVE) {
// do some thing here
return true;
} else if (e2.getX() - e1.getX() > LARGE_MOVE) {
// do some thing here
return true;
}
return false;
} });
}catch(NullPointerException e){
e.printStackTrace();
}
Hope this works for you . Happy Coding
Upvotes: 3