2012-01-02 6 views
0

これは私のコードです。私は私のアプリでマルチストロークジェスチャーを認識するようにしたいが、それは働いていない:アンドロイドでマルチストロークジェスチャーを認識する方法

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>  

答えて

0

セットandroid:gestureStrokeType="multiple"は、複数のストロークを認識するためのジェスチャを行うために使用されることを示します。

私はすでにそれを行うが、私の問題は、私は上のジェスチャー滞在したいですあなたはfadeoffset時間を増やす必要があり、次のチュートリアル

http://developer.android.com/resources/articles/gestures.html

+0

を参照してください。ユーザーがボタンをクリックしてクリックすると、認識プロセスが開始され、結果が表示されます。 – RizN81

+0

この行に問題があります。** setContentView(gestureOverlayView); ** – RizN81

0

多分2000 CUD B役立ち

0
gestureOverlayView.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_MULTIPLE); 
関連する問題