質問

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.

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top