I have created a RecyclerView with a very similar design to the one mentioned
and even used the excellent self-supplied solution in my implementation. Basically I have a RecyclerView that expands upon click to show an extra layout component for that entry.
That worked fine however once the view was expanded it sometimes got recycled and when scrolling to new views they would sometimes appear on screen in an expanded state which isn't what I was after. To resolve this I followed the advice from
and set
holder.setIsRecyclable(false);
when clicked. This also seemed to work fine.
My only issue is that I now get the following error in my logs when the app is running and multiple views are getting clicked/scrolled/expanded/recycled.
isRecyclable decremented below 0: unmatched pair of setIsRecyable() calls
As far as I can tell I have a matching call to set the view back to recyclable, so can anyone shed some more info on what is causing the above error and what I need to do to resolve it? Full snippet of offending code below, this is in my onClickListener.
if (!isViewExpanded) {
holder.setIsRecyclable(false);
llCompInfo.setVisibility(View.VISIBLE);
llCompInfo.setEnabled(true);
isViewExpanded = true;
scores.get(getAdapterPosition()).setShowCompInfo(true);
} else {
holder.setIsRecyclable(true);
llCompInfo.setEnabled(false);
isViewExpanded = false;
scores.get(getAdapterPosition()).setShowCompInfo(false);
}