Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable drag to select in RecyclerView SelectionTracker?

I need to disable the drag to select feature of RecyclerView selection tracker. Currently after long press item gets selected and if I continue dragging continuous items are selected. I need to ensure that rest items are not selected.

Tried working something with the inbuild implementations but nothing worked.

like image 996
Aditya Kolsur Avatar asked Jun 21 '19 11:06

Aditya Kolsur


1 Answers

In your SelectionTracker.Builder there is a method withSelectionPredicate(SelectionPredicate). You can define your own SelectionPredicate and implement its abstract method canSelectMultiple to return false - with this you will be able to select only the single item.

Hope it helps.

like image 81
Pavlo Ostasha Avatar answered Oct 04 '22 07:10

Pavlo Ostasha