2012-01-31 56 views
0
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

安置自己的logcat輸出.. – 2012-01-31 09:59:51

+0

謝謝。它已成功完成並更正 – Nansu 2012-02-14 08:46:46

回答

0

可能是你得到空指針,因爲你的gesturelib是行空(gesturelib = GestureLibraries.fromRawResource(這一點,R.raw.gestures);)

相關問題