I am retrieving a list of database records and displaying them using a ListView. In my bindView method in my SimpleCursorAdapter i manipulate the data to display to my requirements. This works fine.
I however want to add the data retrieved to a list, so thought I could do that in each bindView method call and store on a private variable in the Activity. What subsequently happens is that my list grows to 21 items in size whereas there are only 7 results displayed in the layout.
Why does this happen? If i add a breakpoint, I can see it’s hitting the method 21 times.. Its definitely is a multiple of 3 thing too, as if i have 8 items in my cursor, I end up with 24 in my list.
I don’t think you should be using the data retrieved for your list view to populate a local variable. It would make more sense to just pull this data back and populate the var in a separate call. The ListView operation is complicated and you are best to stick with the standard ways of using it. This is worth watching.