Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SelectionTracker.Builder isn't working IllegalArgumentException

I am trying to implement recyclerView multi-selection but I get java.lang.IllegalArgumentException on StorageStrategy.createLongStorage()

here is my code

tracker = new SelectionTracker.Builder<>("selection1"
                , recyclerView
                , new StableIdKeyProvider(recyclerView)
                , new MyItemDetailsLookup(recyclerView)
                , StorageStrategy.createLongStorage())
                .withSelectionPredicate(SelectionPredicates.<Long>createSelectAnything())
                .build();
like image 414
Shahryar Khosravi Avatar asked Apr 04 '19 21:04

Shahryar Khosravi


2 Answers

You need to call recyclerView.setAdapter(...) before SelectionTracker.Builder<>(...).build()

like image 50
elementstyle Avatar answered Oct 22 '22 06:10

elementstyle


This is probably because at this point the adapter of the RecyclerView has not been set.

like image 41
Jose Hidalgo Avatar answered Oct 22 '22 06:10

Jose Hidalgo