public class GusterActivity extends Activity implements OnGesturePerformedListener
{
TextView txtmsg;
TextView txtwrt;
private GestureLibrary gesturelib;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GestureOverlayView gestureoverlayview=new GestureOverlayView(this);
View inflate=getLayoutInflater().inflate(R.layout.main,null);
gestureoverlayview.addView(inflate);
gestureoverlayview.addOnGesturePerformedListener(this);
gesturelib= GestureLibraries.fromRawResource(this,R.raw.gestures);
if(gesturelib.load()){
finish();
}
setContentView(gestureoverlayview);
}
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gesturelib.recognize(gesture);
for(Prediction prediction : predictions){
if(prediction.score>1.0){
Toast.makeText(this,prediction.name,Toast.LENGTH_SHORT);
}
}
}
答案 0 :(得分:0)
可能是因为你的gesturelib在行中是null,所以你得到了nullpointer(gesturelib = GestureLibraries.fromRawResource(this,R.raw.gestures);)