ListView数据更新后,自动滚动到底部(聊天时常用)| Listview Scroll to the end of the list after updating the list_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > ListView数据更新后,自动滚动到底部(聊天时常用)| Listview Scroll to the end of the list after updating the list

ListView数据更新后,自动滚动到底部(聊天时常用)| Listview Scroll to the end of the list after updating the list

 2013/9/10 12:06:41  攻城大師  博客园  我要评论(0)
  • 摘要:IfyouwouldliketoafteryouhaveupdatedbylistAdapter,youwanttomakesurethatthelistisscrolledallthewaytothebottom,sothatitdisplaysthelastelemententeredinthelist.Youcandothis.Method1:mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL)
  • 标签:view 常用 list 数据

If you would like to after you have updated by listAdapter, you want to make sure that the list is scrolled all the way to the bottom,

so that it displays the last element entered in the list. You  can  do this .

 

Method1:

mListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

Method2:

set this attribute in XML

class="html">android:transcriptMode="alwaysScroll"

Method3:

if the above two methods fail, you can try this:

you can manually tell the list to scroll to the bottom by setting the list selection to the last row.

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);
        }
    });
}

 

From:http://stackoverflow.com/questions/3606530/listview-scroll-to-the-end-of-the-list-after-updating-the-list



 

上一篇: WP开发者观望心态重 微诺生态谋走出死循环 下一篇: 没有下一篇了!
发表评论
用户名: 匿名