これは私のコードです。私は私のアプリでマルチストロークジェスチャーを認識するようにしたいが、それは働いていない:アンドロイドでマルチストロークジェスチャーを認識する方法
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>
。
を参照してください。ユーザーがボタンをクリックしてクリックすると、認識プロセスが開始され、結果が表示されます。 – RizN81
この行に問題があります。** setContentView(gestureOverlayView); ** – RizN81