列表视图滚动到列表的末尾更新列表后, [英] Listview Scroll to the end of the list after updating the list

查看:195
本文介绍了列表视图滚动到列表的末尾更新列表后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以确保该列表滚动一路底部,之后我已使用listAdapter更新的列表视图,使其显示在列表中输入的最后一个元素。我怎样才能做到这一点?

I would like to make sure that the list is scrolled all the way to the bottom, after I have updated the listview by using listAdapter, so that it displays the last element entered in the list. How can I do this ?

我试过,但没有运气:

lv.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

谢谢

推荐答案

假设你知道什么时候该列表的数据发生了变化,您可以手动告诉列表的列表选择设置到最后一行滚动至底部。是这样的:

Supposing you know when the list data has changed, you can manually tell the list to scroll to the bottom by setting the list selection to the last row. Something like:

private void scrollMyListViewToBottom() {
    myListView.post(new Runnable() {
        @Override
        public void run() {
            // Select the last row so it will scroll into view...
            myListView.setSelection(myListAdapter.getCount() - 1);
        }
    });
}

这篇关于列表视图滚动到列表的末尾更新列表后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆