GestureOverlayView不工作

问题描述:

我有种puzzeld现在是:GestureOverlayView不工作

我使用Gesturebuilder 1手势是刷卡朝上 2手势指向下方 3手势挥动创建4个手势是一个轻扫指向左边 4手势是指向右侧

刷卡,但是当我试图让上运行的应用程序的手势 只左右是公认的,但也是它接缝像上下都同样喜欢左,右 因为该方法给出了我的获取作为一个toat

敬酒的刷卡左边显示:向上,向左

我也用我的活动自定义视图和OntouchListener但我不能让它工作

活动:

public class RunActivity extends Activity implements OnTouchListener, OnGesturePerformedListener { 

    static int width; 
    static int height; 

    static boolean reset=false; 


    draw d; 


    //jump 
    private GestureLibrary gestureLib; 


private static Context mContext; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     d = new draw(this); 
     d.setOnTouchListener(this); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
           WindowManager.LayoutParams.FLAG_FULLSCREEN); 

     mContext = this; 


     //get screen size 
     WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE); 
     Display display = wm.getDefaultDisplay(); 


     width = display.getWidth(); // deprecated 
     height = display.getHeight(); // deprecated 


     //Jump 
     GestureOverlayView gestureOverlayView = new GestureOverlayView(this); 
     View inflate = d; 
     gestureOverlayView.addView(inflate); 
     gestureOverlayView.addOnGesturePerformedListener(this); 
     gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures); 
     if (!gestureLib.load()) { 
      finish(); 
     } 
     setContentView(gestureOverlayView); 

     //setContentView(d); 
    } 
    public static Context getContext(){ 
     return mContext; 
    } 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     Log.d("touch","touched"); 

     if (draw.end == true) 
     { 
     reset=true; 
     } 
     return false; 
    } 
    @Override 
    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) 
         .show(); 
      } 
     } 
    } 

} 

删除你的onTouch()方法,或者至少链接到超类,而不是简单地返回false,看看是否有帮助。

+1

我曾尝试过,但上/下手势仍然无法识别 – user1293780 2012-04-11 13:47:24

+0

您是否解决了这个问题? – Sarvesh 2013-06-13 07:47:04

+0

这似乎与我的手势执行相同的问题。有任何想法吗 ? – Sarvesh 2013-06-14 21:05:30