這是我的代碼。我想識別我的應用程序中的多筆畫手勢,但它不起作用:如何識別android中的多筆畫手勢
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 2012-01-02 08:11:41
我有這個問題** setContentView(gestureOverlayView); ** – RizN81 2012-01-02 12:51:22