Это мой код. Я хочу распознать мульти-штриховой жест в моем приложении, но он не работает:
gestureOverlayView.addOnGesturePerformedListener(new OnGesturePerformedListener()
{
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture)
{
ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
if (predictions.size() > 0)
{
prediction = predictions.get(0);
if (prediction.score > 1.0)
{
DrawText = prediction.name;
Toast.makeText(testone.this, "You Draw" + DrawText,Toast.LENGTH_LONG).show();
if(DrawText.equalsIgnoreCase("E"))
{
Toast.makeText(testone.this, "Z", Toast.LENGTH_LONG).show();
}
}
}
}
});
но когда я иду рисовать жест, он сразу исчезает.
Это мой макет xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gesture Test"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Check"
android:id="@+id/checkit"
/>
<android.gesture.GestureOverlayView
android:id="@+id/GalleryGesture"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:gestureStrokeType="multiple"
android:fadeOffset="1000">
</android.gesture.GestureOverlayView>
</LinearLayout>
Я хочу распознать жест, когда пользователь нажимает кнопку.