Use OnClickListener instead of OnCheckedChangeListener. The latter works even if you update the redesigned view to match the value of the object. In the following snippet of getView () code, I use HashMap to store the object validation value (itemMap).
boolean checked=itemMap.get(currentObject); if(checked!=checkBox.isChecked()) checkBox.setChecked(checked); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CheckBox checkBox1=(CheckBox)v; if(checkBox1.isChecked()) //ckecked { itemMap.put(currentObject,true); if(checkListener!=null) checkListener.onCheck(position,convertView,parent,adapter); } else{ //unchecked itemMap.put(currentObject,false); if(checkListener!=null) checkListener.onUnCheck(position,convertView,parent,adapter); } } });
checkListener is an additional listener that can be added by the class user.
source share