Android Listview With Checkbox: Automatically Unchecks
I've got a ListView with a custom BaseAdapter. The list items contain CheckBoxes that need to represent a property from a database. I use CheckBox.setOnCheckedChangeListener with a
Solution 1:
Apparently the problem was that, by getting the checkbox using convertView.findViewById(), the onCheckedChangeListeners were still intact if the view was recycled. Calling checkbox.setOnCheckedChangeListener(null) did the trick.
Solution 2:
Use a boolean array to store the checked state of each list item, record the changes inside setOnCheckedChangeListener()
, then call setChecked()
aftersetOnCheckedChangeListener()
.
Post a Comment for "Android Listview With Checkbox: Automatically Unchecks"