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>
どんな助けでも素晴らしいでしょう。