开发者

Android ListViews and Dynamic Section Headers

I have an Array that I pass to a CustomAdapter for a ListView. The array has items that are already sorted. Something like:

[{"stuff":[{"stuff_id": "1", "value":"test123"},
 {"stuff_id": "1", "value":"test123"},
 {"stuff_id": "2", "value":"test123"}]}]

The Array changes allot so I do not know haw many sections I w开发者_开发问答ill have. So far I am finding weird results when using a device versus using the emulator. For instance, I Logcat the position in the getView() method every time its called and with the emulator, I only get 0 once. With a device (Motorola Droid - 2.1), every forth row or so is position 0. I figure it has something to do with the screen size and reuse but i am not sure.

I tried to use login like, if(position == 0) draw section header and then if(stuff_id != previous_stuff_id) draw section header. But since the position goes back to zero, I get header rows where I should not.

Anyone seen these types of results and know how to fix them?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜