Android中Activity中左右滑动手势的监听

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Android中Activity中左右滑动手势的监听
/* 
     * 完成对左右划屏 
     */  
    @Override  
    public boolean onTouchEvent(MotionEvent event) {  
  
        switch (event.getAction()) {  
        case MotionEvent.ACTION_DOWN:  
            prev.set(event.getX(), event.getY());  
  
            break;  
        case MotionEvent.ACTION_UP:  
            break;  
  
        case MotionEvent.ACTION_MOVE:  
  
            float moveX = prev.x - event.getX();  
  
            // 左滑  
            if (moveX > 150 && moveX < 5000) {  
                // mDesignClothesBackground  
                // .setBackgroundResource(idClothesBackground[0]);  
            }  
            // 右滑  
            else if (moveX < -150 && moveX > -5000) {  
                // mDesignClothesBackground  
                // .setBackgroundResource(idClothesBackground[1]);  
            }  
  
        }  
  
        return false;  
    }