Android: How to handle right to left swipe gestures

前端 未结 22 1162
日久生厌
日久生厌 2020-11-21 06:18

I want my app to recognize when a user swipes from right to left on the phone screen.

How to do this?

22条回答
  •  感情败类
    2020-11-21 07:20

    @Edward Brey's method works great. If someone would also like to copy & paste the imports for the OnSwipeTouchListener, here they are:

     import android.content.Context;
     import android.view.GestureDetector;
     import android.view.GestureDetector.SimpleOnGestureListener;
     import android.view.MotionEvent;
     import android.view.View;
     import android.view.View.OnTouchListener;
    

提交回复
热议问题