10
As I mentioned on title, app has a ScrollView and a GestureDetector too. Outside of ScrollView's touch events, GestureDetector handling swipe actions like left to right and right to left. They're all working well.
Now I want to add a GestureLibrary -I mean raw- to Activity. I've looked different sources and somehow added properly. Simply, layout looking like this:
<android.gesture.GestureOverlayView
android:id="@+id/gOverlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="@+id/content_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none">
</ScrollView>
<!-- Other views -->
</android.gesture.GestureOverlayView>
It's drawing as I wanted (the yellow line) but it's not triggering any methods. Here how I implemented OnGesturePerformedListener:
/*
* Gestures
*/
gLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!gLibrary.load()) { finish(); }
GestureOverlayView gestureOverlayView = (GestureOverlayView) findViewById(R.id.gOverlay);
gestureOverlayView.addOnGesturePerformedListener(gestureListener);
And here is gestureListener:
private OnGesturePerformedListener gestureListener = new OnGesturePerformedListener() {
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gLibrary.recognize(gesture);
if (predictions.size() > 1) {
for(Prediction prediction: predictions){
Log.d("Test", "Looking for gestures");
}
}
}
};
That's all. By the wall, I tried this source code with in different Activity which