如何以编程方式滚动到 ListView 的底部?

编程入门 行业动态 更新时间:2024-10-25 07:18:32
本文介绍了如何以编程方式滚动到 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 的底部?

本文发布于:2023-11-11 17:58:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579163.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   ListView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!