I have an Android ListView with rows that include one checkbox, and four text views per row. It’s a multiple choice list view. By default, the list view starts with some rows already checked. You can check or uncheck any row. When a user clicks the row (not the checkbox), all the rows have their checkboxes reverted back to default.
- Why is this happening?
- How do I stop it?
UPDATE
I’m using the default ListView with a SimpleAdapter and ArrayList<String, Object>
So after playing around with my code, I had an idea of what was causing the default value restore and how to stop it.
The default value restore was issued because the items were getting re-painted. This re-paint was occurring because the click was highlighting, and (de)activating the list item. Why it happens to all the list items is beyond me, but this caused the list view to re-draw them using their default values.
That means to stop this from happening, I should modify the source list to be “selected” when it was clicked (or “unselected” if it was already selected). Then when the re-paint occurred, the checkbox would be checked (or unchecked) appropriately.