Checkbox auto call onCheckedChange when listview scroll?

The ListView recycles the view classes: you will need to explicitly set whether or not the CheckBox is checked in the getView class. So add a check like

/**
*    Ensure no other setOnCheckedChangeListener is attached before you manually
*    change its state.
*/
mViewHolder.checkbox.setOnCheckedChangeListener(null);
if(shouldBeChecked) mViewHolder.checkbox.setChecked(true);
else mViewHolder.checkbox.setChecked(false);

before you call setOnCheckedChangeListener.

Leave a Comment