Reputation: 441
I want to use Gesture
in my application. So I've checked out this documentation and createad a gesture already. Then copied that gesture to my raw
folder which is located to res/
.
Everything is okay from here, then I impelement OnGesturePerformedListener
as 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");
// 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) {
// Show the spell
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
}
}
}
The problem is when I try to draw gesture nothing changes. Even onGesturePerformed
not working. What's problem?
I'm not sure but maybe layout could cause, 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.
Upvotes: 5
Views: 228
Reputation: 6073
You ought to fill entire gesture area with GestureOverlayView. Changing
android:layout_height="0dip"
to
android:layout_height="fill_parent"
Should do the trick.
Upvotes: 3