问题
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:
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.
来源:https://stackoverflow.com/questions/1473355/autogrow-listview-in-android