How to differentiate between a fling and a touch?

后端 未结 2 1139
谎友^
谎友^ 2021-02-03 15:56

I have a ListView inside of a ViewFlipper which I am flipping when the user swipes across the screen. Clicking on a ListView will open the browser. Sometimes when I am swiping,

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-03 16:07

    Have you tried using SimpleOnGestureListener.onSingleTapConfirmed(MotionEvent) for the on touch event ("click")? This will only be called after the detector is confident that the user's first tap is really a tap and not a double tap (or hopefully a fling).

    class MyGestureDetector extends SimpleOnGestureListener {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent event) {
            // Code...
        }
    }
    

提交回复
热议问题