5

Gestureアプリケーションで使用したい。だから私はこのドキュメントをチェックして、すでにジェスチャーを作成しました。raw次に、そのジェスチャーをにある私のフォルダにコピーしましたres/

ここからすべてが大丈夫です、それから私はOnGesturePerformedListener以下に示すように要素を追加します:

if(!mLibrary.load()) {
    Log.d("Tag", "Couldn't load");
} else {
    Log.d("Tag", "Loaded");
    GestureOverlayView gesture = (GestureOverlayView) findViewById(R.id.gestures);
    gesture.addOnGesturePerformedListener(this);
}

そして最後にここに私のリスナーがあります:

public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    Log.d("Tag", "Performed");
    // We want at least one prediction
    if (predictions.size() > 0) {
        Prediction prediction = predictions.get(0);
        // We want at least some confidence in the result
        if (prediction.score > 1.0) {
            // Show the spell
            Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT).show();
        }
    }
}

問題は、ジェスチャーを描画しようとしても何も変わらないことです。動作していなくてもonGesturePerformed。何が問題なの?

よくわかりませんが、レイアウトが原因である可能性があります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/splash_bg"
    android:screenOrientation="portrait" >

    <android.gesture.GestureOverlayView
        android:id="@+id/gestures"
        android:layout_width="fill_parent" 
        android:layout_height="0dip"
        android:layout_weight="1.0" />    

</RelativeLayout>

どんな助けでも素晴らしいでしょう。

4

1 に答える 1

3

ジェスチャ領域全体をGestureOverlayViewで埋める必要があります。変化

android:layout_height="0dip"

android:layout_height="fill_parent"

トリックを行う必要があります。

于 2012-08-22T11:04:32.177 に答える