Reference post: http://www.myexception.cn/mobile/1852852.html
When using Recycleview to make a copy image selector, where the checkbox is used in the entry, the checkbox is selected as a result of holder reuse, and the solution is as follows:
Requires two list one to place the tag tag, one for placing the selected picture path.
Holder.checkBox.setTag (NewInteger (position));//A problem that prevents multiple selection of checkboxes caused by reuse. //prevent check of secondary list checkpositionlist if(Checkpositionlist! =NULL) {holder.checkBox.setChecked (Checkpositionlist.contains (NewInteger (position))?true:false)); } Else{holder.checkBox.setChecked (false); } holder.checkBox.setOnCheckedChangeListener (NewCompoundbutton.oncheckedchangelistener () {@Override Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) { if(isChecked) {if(!Checkpositionlist.contains (Holder.checkBox.getTag ())) {Checkpositionlist.add (NewInteger (position)); Checkedimgs.add (Currentimgpath); } }Else { if(Checkpositionlist.contains (Holder.checkBox.getTag ())) {Checkpositionlist.remove (holder.checkb Ox.gettag ()); Checkedimgs.remove (Currentimgpath); } } } });
Duplicate check problems caused by using a checkbox in Recycleview