Double Click OnClickListener of a Recycler View Adapter

后端 未结 2 868
花落未央
花落未央 2021-02-15 11:16

I am trying to add a simple Click View to an item of a recycler view, but for some reason I have to click on an item twice instead of once to perform an action. On single click

相关标签:
2条回答
  • 2021-02-15 11:47

    I had a similar problem, but the solution of setting focusable to false did not work in my case.

    Instead, my problem was what I had set the onItemTouch listener in the activity that was holding my recycler view.

    recyclerView.addOnItemTouchListener(...);
    

    By removing this from my activity, my other touch listeners started to respond on single taps and not only double.

    0 讨论(0)
  • 2021-02-15 12:04

    So I found the issue. The following two tags were the culprits here

    android:focusable="true"
    android:focusableInTouchMode="true"
    

    When we set focusable and focusableInTouchMode = true basically it means that you are enabling a view to first focus on a touch and then be able to click.

    0 讨论(0)
提交回复
热议问题