I cannot solve an issue with the getGroupView-method.
the problem is that the listener setOnCheckedChangeListener is getting invoked to many times.
Let say
What version of Android are you using?
It seems to be an issue for multiple components, especially with a checkedChange() method (CheckBox, RadioButton) and I can't provide a good explanation why it is happening.
I would assume because it registers the change of the position state and grabs the change of other properties? A similar issue was addressed here
In any case, a workaround around this could be to add an OnClickListener()
.
CheckBox yourCheckBox = (CheckBox) findViewById (R.id.yourId);
yourCheckBox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//is chkIos checked?
if (((CheckBox) v).isChecked()) {
//Case 1
}
else
//case 2
}
});
I faced the same problem and struggled for several hours seeing all discussions related to this. I tried to fix this by keeping
viewHolder.checkBox.setTag(groupPosition);
this statement before viewHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
this listener. And the code works exactly as expected.