In adapter:
1 Private New Arraylist<> ();
In the following method:
1 Public void Onbindviewholder (finalfinalint
Set the item's root layout tag to the current position:
// sets the view of the item background color, Settag itto ItemViewHolder.rl_item.setTag (position);
When judging, you can get the tag value of root layout, judge it, and set the item's current state.
1 if(Checkboxuseridlist.contains (ItemViewHolder.rl_item.getTag ())) {2ItemViewHolder.rl_item.setEnabled (false);3ItemViewHolder.check_box.setEnabled (true);4 ItemViewHolder.rl_item.setBackgroundResource (R.COLOR.GRAY_BG);5}Else {6ItemViewHolder.rl_item.setEnabled (true);7ItemViewHolder.check_box.setEnabled (false);8 ItemViewHolder.rl_item.setBackgroundResource (r.color.white);9}
This is due to the viewholder reuse, which causes the state of the disorder, so want to solve the state problem of this item:
1, Viewholder will not be reused, there is no checkbox confusion selected problems, but when you swipe the card to die:
1 viewholder.setisrecyclable (false
2. Set a flag bit in the bean that gets to it, but you need to modify the bean. Although it's just a matter of adding a field, it's not recommended.
3, that is, the code written above.
Reference: In fact, the same as the ListView reuse.
Recycleview checkbox multiplexing Chaotic Solution
Android ListView checkbox Status disorder
Recyclerview Item Status Disorder