Checkbox in Recyclerview Android | Recyclerview with checkbox android
Hello warriors..how are you guys ?? I hope you all are doing something great..So i m back after a long time with a cool and very helpful topic of internet Recyclerview with checkbox android. few month ago i was working on a project and i faced a very weird problem in recyclerview with checkbox ,checkbox unchecked when i scroll recyclerview and i know a lot of developer facing this problem at initial stage so in this post i am going to share with you solution of this problem.
I hope all of you know how to create Recyclerview with checkbox in android i am going to discuss only about android recyclerview checkbox scroll problem for this i have created a simple recyclerview with checkbox with 500 item.
So here is my activity_main.xml :-
here is my MainActivity.java :-
Finally here is my adapter class :-
To solve this problem you need to do follow three steps:
- Create a HashMap in your adapter class of <Integer,Boolean> type.
- Update HashMap inside checkChangeListener of Checkbox inside your ViewHolder.
- Check whether checkbox is already checked or not inside onBindViewHolder.
All these steps are included in my adapter class. i hope this post will help you to solve android recyclerview checkbox scroll problem if this is helpful for you don't forget to give your feedback in comment.you can download complete code from below download button.