Aditya Kolsur
Aditya Kolsur

Reputation: 111

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.

Upvotes: 11

Views: 1312

Answers (1)

Pavlo Ostasha
Pavlo Ostasha

Reputation: 16729

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.

Upvotes: 3

Related Questions