Scroll to end in a PullToRefreshListView

◇◆丶佛笑我妖孽 提交于 2019-12-12 04:08:49

问题


How do I programmatically upon inserting new items to a PullToRefreshListView scroll so that the last item is visible?

Here is some code:

listView = (PullToRefreshListView) findViewById(R.id.list);
listView.setAdapter(someAdapter);

And I would like to do:

listView.scrollToEnd();

or

someAdapter.scrollToEnd();

or something similar.


回答1:


You can set the TranscriptMode on a ListView to have it always scroll to the bottom when new content is added

listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

You can also use

listView.scrollTo(0, listView.getHeight());



来源:https://stackoverflow.com/questions/23502365/scroll-to-end-in-a-pulltorefreshlistview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!