我的Toast没有提示,哪里错了
package com.example.test;
import java.util.ArrayList;
import android.app.Activity;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.gesture.Prediction;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends Activity {
// 1.声明控件
GestureOverlayView gestureOverlayView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 2.绑定控件
gestureOverlayView = (GestureOverlayView) findViewById(R.id.gestureOverlayView1);
/*
* 3.找到刚才预设定的手势文件 4.加载那个手势文件中的所有手势 5.匹配 识别
*/
// 从资源中将手势文件加载进来
final GestureLibrary library = GestureLibraries.fromRawResource(MainActivity.this, R.raw.gestures);
library.load();
// 6.添加监听器
gestureOverlayView.addOnGesturePerformedListener(new OnGesturePerformedListener() {
@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
// TODO Auto-generated method stub
// 读出手势中内容 识别手势
ArrayList<Prediction> myArrayList = library.recognize(gesture);// 返回的是集合
// 遍历手势
Prediction prediction = myArrayList.get(0);
// prediction——相似度
if (prediction.score >= 2.0) {//值越小,越好识别(Ps:取值范围:0.00——10.00)
if (prediction.name.equals("exit")) {
finish();
}
else if (prediction.name.equals("next")) {
Toast.makeText(MainActivity.this, "播放下一首", Toast.LENGTH_SHORT).show();
}
else if (prediction.name.equals("pervious")) {
Toast.makeText(MainActivity.this, "播放上一首", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(MainActivity.this, "没有该手势", Toast.LENGTH_SHORT).show();
}
}
});
}
}
只有提示没有手势……,貌似进不了if里面去