-1

To be more specific, I want to know that how can we select all items in a custom list in recycler view(list is made up of only checkbox) by clicking a checkbox which says select all.

Beginner
  • 1
  • 1
  • 2
  • 2
    Possible duplicate of [Selecting All Items in a Listview on checkbox select](http://stackoverflow.com/questions/24690605/selecting-all-items-in-a-listview-on-checkbox-select) – Bill Jul 14 '16 at 19:47
  • Well if you inflate a row with a checkbox in it then it will be shown, so you could have a layout with your content and a checkbox and when you click on check all excute a code in your recycler view adapter to display the checkbox view. – kabuto178 Jul 14 '16 at 19:47
  • http://stackoverflow.com/questions/39329079/select-all-checkboxes-in-recyclerview?noredirect=1&lq=1 – Ahmed Karam Dec 15 '16 at 09:34

2 Answers2

1

WHen the select all box is clicked, walk through your children's data models and set the selected flag on all of them to true. Then call notifyDataSetChanged on the adapter to redraw the view.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
0

create a list with CheckBox in adapter class

List<CheckBox> intradayCheckboxsList = new ArrayList<>();

and add every CheckBox to list in onBindViewHolder()

intradayCheckboxsList.add(holder.interested_item_checkbox);

in onCheckedChanged() method call this method

void checkBoxOperation(List<CheckBox> checkBoxList,boolean what){
        for (CheckBox checkBox : checkBoxList ){
            checkBox.setChecked(what);
        }
    }

what true it will check all

what false it will uncheck all

saigopi.me
  • 14,011
  • 2
  • 83
  • 54