如何以编程方式滚动到ListView的底部? [英] How to scroll to the bottom of ListView programmatically?
本文介绍了如何以编程方式滚动到ListView的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在调用notifydatasetchanged();
之后,我想滚动到列表的底部,以便用户看到Listview中的最后一条记录.
After calling notifydatasetchanged();
I want to scroll to the bottom of list so that user see the last record in the Listview.
(我正在编写聊天模块,因此,需要在列表底部显示最新记录)
(I am writing Chat module so for that purpose I need latest record at the bottom of list to be visible)
任何人都可以指导我如何实现这一目标吗?
Can any one guide me how to achieve this?
推荐答案
尝试
listView.post(new Runnable(){
public void run() {
listView.setSelection(listView.getCount() - 1);
}});
根据我的经验,发布"似乎是必需的,特别是如果您最近更新了该列表.
The 'post' seems to be required sometime in my experience, particularly if you have very recently updated the list.
这篇关于如何以编程方式滚动到ListView的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文