In your activity:
GestureLibrary gLibrary;
GestureOverlayView mView;
String txtToDisplay="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (gLibrary != null) {
if (!gLibrary.load()) {
Log.e("GestureSample", "Gesture library was not loaded…");
finish();
} else {
mView = (GestureOverlayView) findViewById(R.id.gestures);
mView.addOnGesturePerformedListener(this);
}
}
}
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gLibrary.recognize(gesture);
// one prediction needed
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// checking prediction
if (prediction.score > 1.0) {
txtToDisplay+=prediction.name;
yourTextView.setText(txtToDisplay);
}
}
}
}
In the XML you need to put this where you want to get the gestures recognized:
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gestureColor="#2a69a5"
android:uncertainGestureColor="#e2e2e2" >
</android.gesture.GestureOverlayView>
AND you need the library of gestures. Follow the first step of this tutorial: Android Gestures Tutorial