如何在android中检测手指滑动

如何在android中检测手指滑动,android,swipe,touch-event,Android,Swipe,Touch Event,我尝试进行手指滑动,但未检测到。我尝试绘制一条路径,描述手指滑动的区域,但仅当我用力滑动时,才检测到滑动,否则未检测到滑动 public boolean onTouchEvent(MotionEvent event) { if (System.currentTimeMillis() - lastClick > 500) { lastClick = System.currentTimeMillis(); synchronized (getHolder()) {

我尝试进行手指滑动,但未检测到。我尝试绘制一条路径,描述手指滑动的区域,但仅当我用力滑动时,才检测到滑动,否则未检测到滑动

public boolean onTouchEvent(MotionEvent event) {
if (System.currentTimeMillis() - lastClick > 500) {
       lastClick = System.currentTimeMillis();
       synchronized (getHolder()) {
           int eventaction = event.getAction();
           if(event.getPressure()>0.00001||event.getSize()>0.00001)
           {

           float a,b,c;
           switch(eventaction)
           {
           case MotionEvent.ACTION_DOWN:

               xdown = event.getX();
               ydown =event.getY();
               pres=true;

               break;

           case MotionEvent.ACTION_MOVE:
               if(pres)
               {

               xmove = event.getX();
               ymove =event.getY();
               a = (float) Math.sqrt(Math.pow(xdown - xmove,2) +Math.pow( ydown - ymove,2)); 
            b=(float) (xdown-(((xdown - xmove) / a) * 150));
            c=(float) (ydown-((( ydown - ymove)/a)*150));
            move.moveTo(xdown, ydown);
            move.lineTo(b, c);
               pres=false;
               lmove=true;

               }
               break;
           case MotionEvent.ACTION_CANCEL:
           case MotionEvent.ACTION_POINTER_UP:
               move.reset();
                   xmove = 0;
                   ymove =0;
                   xdown=0;
                   ydown=0;
               lmove=false;
               pres=false;
               break;
           default:
               return true;

           }
       }
       }}
return true;

       } 

Android有一个这样的类。检查 我相信这是一个接触事件

请参见此处的代码:

使用SimpleOnGestureListener是最简单的,如果重写onFling方法,则很容易/

可能会重复