Reputation: 588
I have a simple RecyclerView and I want to remove those items onClick. I was continuously running into a crash depending on when I clicked on certain items in the list with the above error. If you're having similar issues, here's how I solved it:
Upvotes: 1
Views: 2514
Reputation: 588
public void onBindViewHolder(final CardViewHolder holder, final int position)
Using position here is useful for some things, but if I used it when removing items from the list, it was causing a crash, instead using:
holder.getAdapterPosition();
resolved my issues immediately.
Upvotes: 7