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
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);
}
});
}
本文详细介绍了如何使用ListView的TranscriptMode属性、XML设置和手动滚动到ListView底部的方法来确保列表滚动到最底部,展示最新添加的元素。


7473

被折叠的 条评论
为什么被折叠?



