在android中的listview实现中加载更多消息
我在列表视图中显示从服务器获取的前 20 条记录。
我有一个baseadapter,它作为适配器绑定到listview,并且我将从服务器获取的记录传递到这个baseadapter。
我将页脚项目设置为附加到列表视图的文本视图,相同的 onclicklistener,它从服务器获取新的 20 条记录,然后我添加这 20 条记录并传递给 baseadapter。
但它再次重新加载整个列表视图,并显示所有 40 条记录,但从列表项 1 开始。
我想显示整个列表,但光标点应该来自列表中添加的新项目,类似于 android 中的“电子邮件应用程序”。
换句话说,只有新项目才应该刷新
I display first 20 records fetched from server in a listview.
I have baseadapter which is binded to listview as an adapter, and i pass records fetched from server to this baseadapter.
I set a footer item as textview attached to listview, onclicklistener of same, it fetches new 20 records from server, then i add those 20 records and pass to baseadapter.
But it reloads whole listview again, and displays all 40 records but starting from list item 1.
I want to display whole list but cursor point should be from new items added in list, as similar to "Email application" in android.
In other words, only new items should be refreshed to
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您需要在通知适配器时调用以下代码。
它从顶部设置您的项目。
For that you need to call the below code when you notify your adapter.
It set your item from the top.
您的应用程序可以保留当前列表视图位置,并且在更新列表视图后您可以通过 setPosition 方法导航到该位置
Your app can keep current listview position and after updting listview you can navigate to this position through setPosition method