I'm trying to implement a choice mode for my RecyclerView. However, I'm having a problem while trying to deselect previously checked items. My approach goes like:
if (selectedPosition >= 0) {
RowHolder row = (RowHolder)recyclerView.findViewHolderForAdapterPosition(selectedPosition);
if (row != null) {
row.setChecked(false);
}
}
The issue occurs when the next elements following what's currently presented, usually 1 or 2, are subject to the deselection (i.e in case 5 elements can fit into the screen, then interacting with elements at position 6 and 7 is the source of the problem.)
In this scenario, findViewHolderForAdapterPosition(position) returns null, and the adapter's onBindViewHolder(RowHolder holder, final int position) is not being called.
However when all the elements fit into a single preview (No scrolling needed to preview more items) things work as expected.
Anyone has a clue what could be a solution for that?
Readers of Commonsware book, the same issue exists with the RecyclerView/SingleActivatedList sample.