This is my code to set the child view. I set the first Child is the select all layout then the layout for the child for the rest. When I press select all checkbox nothing happens.
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ArrayList<CheckBox> myCheckBoxes = new ArrayList<>();
if(childPosition == 0){
convertView = inflater.inflate(R.layout.child_header, null);
chkBoxselectAll = convertView.findViewById(R.id.chk_select_all);
} else {
convertView = inflater.inflate(R.layout.child_row, null);
chkBoxsurvey = convertView.findViewById(R.id.chk_survey);
for (int i = 0; i < parent.getChildCount(); i++) {
View v = parent.getChildAt(i);
if(v.getId() == (R.id.chk_survey))
myCheckBoxes.add((CheckBox)v.findViewById(R.id.chk_survey));
}
}
if (childPosition > 0 && childPosition < getChildrenCount(groupPosition) - 1) {
chkBoxselectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
for (int i = 0; i < myCheckBoxes.size(); i++) {
if(isChecked)
myCheckBoxes.get(i).setChecked(true);
else
myCheckBoxes.get(i).setChecked(false);
}
}
return convertView;
}