views:

747

answers:

1

I did search around various questions related to the one I'm about to ask. I just want to ask it in clear and simple manner and hopefully get a clear and simple answer :)

I have a List of several hundred items that I want to present to the user in ListView widget. Initially I want to start with say 50 items and as user scrolls near the bottom I want to add another 50 and so forth. I think GMail Inbox would be a good example of what I need. I'm not interested in Cursor implementation - the dataset is quite simple as I said for now it's just a List.

Also - say ListView grows too big, it would be nice to start chopping it from the top so it behaves as a sliding ruler at it max showing about 200 rows (with 30 viewable)

+1  A: 

You can try my EndlessAdapter. It wraps a ListAdapter that you supply and lets you load additional data when the user reaches the bottom. You could try also removing items from the top (e.g., remove() on ArrayAdapter), though I'm a bit nervous about that -- Android might not make the right decisions if, say, your list does not change size but the lineup of rows changes.

CommonsWare
Great! Thanks Mark, I'll give it a shot and report back!
DroidIn.net
Did you ever get to try it? I'm just curious about the performance of the endless adapter? Thanks,Faisal
Faisal Abid
I did. At the end I didn't go with Mark's code but here's what I found so far: If I simply add items to the adapter these will not show up. I tried view#invalidate and it's of no use. The only way I can make additional items to show up is to call ListView#setAdapter again. No I don't have to recreate an adapter. The problem is - list jumps up to the first item. I'm getting source code to look what is happening in that call, so stay posted
DroidIn.net
Correction - for solution see this post http://is.gd/4fYeP
DroidIn.net
brack