Android 中的自动增长 ListView
我确实搜索了与我要问的问题相关的各种问题。我只想以清晰简单的方式提出问题,并希望得到一个清晰简单的答案:)
我有一个包含数百个项目的 List
,我想在 ListView< 中向用户展示这些项目/代码> 小部件。最初,我想从 50 个项目开始,当用户滚动到底部附近时,我想添加另外 50 个项目,依此类推。我认为 GMail Inbox 是我需要的一个很好的例子。我对
Cursor
实现不感兴趣 - 正如我所说,数据集非常简单,现在它只是一个 List
。
另外 - 如果 ListView
变得太大,最好从顶部开始切割它,这样它就像一个滑动标尺,最多显示大约 200 行(其中 30 行可见)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试我的
EndlessAdapter
。它包装了您提供的ListAdapter
,并允许您在用户到达底部时加载其他数据。您也可以尝试从顶部删除项目(例如,ArrayAdapter
上的remove()
),尽管我对此有点紧张 - Android 可能不会做出正确的选择例如,如果您的列表大小没有改变但行的排列发生了变化。You can try my
EndlessAdapter
. It wraps aListAdapter
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()
onArrayAdapter
), 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.