Skip to content Skip to sidebar Skip to footer

Android - Unable To Check All The Checkboxes In A Custom Listview Because Of Recycling Issue?

I have a custom listview adapter with a imageview, textview and a checkbox. and i also have a button and a checkbox in my main layout(not in listview). What here i want is to check

Solution 1:

This morning I read an answer of an issue like this, and they recommend we put holder.checkBox.setChecked(itemChecked.get(position)); before holder.checkBox.setOnCheckedChangeListener

So, getView function will be rewritten like this:

public View getView(....)
{
    ...
    holder.checkBox.setChecked(itemChecked.get(position));///move to here
    holder.checkBox.setOnCheckedChangeListener(...);
    ...
)

Solution 2:

Yeah, this recycling is a pain.

Here's what I did: http://dev.kafol.net/2011/11/android-checkbox-listview-un-check-all.html

I'm still having some issues with SharedPreferences, as allthough I have managed to get all the checkboxes checked or unchecked, it still doesn't save the state to sharedpreferences.

Post a Comment for "Android - Unable To Check All The Checkboxes In A Custom Listview Because Of Recycling Issue?"