使用回收者视图选择库选择ReyclerView项目(只需单击即可)

Aun*_*win 4 android android-support-library android-recyclerview

我是RecyclerView选择库的新手。我准备RecyclerView选择多个项目,只需单击一下即可。我的问题是所有文章和教程都表明选择过程始于长按。

如何覆盖以单击即可开始选择?谢谢。

我正在使用 implementation 'androidx.recyclerview:recyclerview-selection:1.0.0'

本教程,我尝试过..

Aun*_*win 8

经过数周的挖掘,我找到了可行的解决方案。根据???

如果要单击选择,只需覆盖inSelectionHotspot(e: MotionEvent)即可返回true

object : ItemDetailsLookup.ItemDetails<Long>() {
        override fun getSelectionKey(): Long? {

            return itemId
        }

        override fun getPosition(): Int {
            return adapterPosition
        }

        override fun inSelectionHotspot(e: MotionEvent): Boolean {
            return true
        }
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参见此处