Passing MotionEvents from RecyclerView.OnItemTouchListener to GestureDetectorCompat

前端 未结 2 1378
醉梦人生
醉梦人生 2020-12-09 00:50

I have a Fragment that implemets RecyclerView.OnItemTouchListener. How do I pass click and long-click motion events only from the RecyclerView to the Gestur

2条回答
  •  攒了一身酷
    2020-12-09 01:10

    I might be late but for visual feedback add this to your list_item layout

    android:background="@drawable/tranparent_selector"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    

    Also, onSingleTapUp can be used instead of onSingleTapConfirmed as tapping is usually fast. So if you tap fast to other items you wont get it working. For fast tapping I prefer onSingleTapUp

提交回复
热议问题