I want to use Gesturein my application. So I checked this documentation and already created a gesture. Then copy this gesture to my folder raw, which is located in res/.
Everything is fine from here, then I impelement OnGesturePerformedListeneras shown below:
if(!mLibrary.load()) {
Log.d("Tag", "Couldn't load");
} else {
Log.d("Tag", "Loaded");
GestureOverlayView gesture = (GestureOverlayView) findViewById(R.id.gestures);
gesture.addOnGesturePerformedListener(this);
}
And finally, here is my listener:
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
Log.d("Tag", "Performed");
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
if (prediction.score > 1.0) {
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
}
}
}
The problem is that when you try to draw a gesture, nothing changes. onGesturePerformedDoesn't even work. What is the problem?
I'm not sure, but maybe the layout can call, here it is:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/splash_bg"
android:screenOrientation="portrait" >
<android.gesture.GestureOverlayView
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0" />
</RelativeLayout>
Any help would be great.
source
share