Michael Little
Michael Little

Reputation: 507

Android custom cursor adapter and BindView

Ok, I hope I don't get slammed for asking such an ambiguous question but I am stumped and don't even know how to ask this. I am going to try as best as possible to communicate my problem and will clarify if needed.

I have two cursors merged using MergeCursor. I also have a custom cursor adapter. In my custom cursor adapter I have overridden BindView. I am noticing strange behavior where items are not showing up in my listview. Essentially I have two textviews for each row in the listview. In the last row one of the fields is empty.

I step through the BindView and I notice it gets executed 3 times. My listview only has 7 items in it (so that's 7x3). All of them show on the screen except one of the fields in item 7. I notice that on two passes though BindView a field value is missing.

What I want to know is, why is BindView executing 3 times. So when I say 3 I mean 3x7. 7 items in the list, so it cycles through BindView 21 times. I hope I'm making sense.

Please don't slam me if this is not clear. I am happy to modify or provide additional info.

Upvotes: 0

Views: 1129

Answers (1)

Erich Douglass
Erich Douglass

Reputation: 52002

What I want to know is, why is BindView executing 3 times. So when I say 3 I mean 3x7. 7 items in the list, so it cycles through BindView 21 times. I hope I'm making sense.

When ListView goes trough the measure phase, it will call newView and bindView on your adapter so it can set the dimensions of the rows (its children) and determine it's own dimensions. In the process, it doesn't retain the views, so they need to be recreated when the views are drawn on the screen. You can look at the ListView source so see exactly what it's doing.

Upvotes: 1

Related Questions