Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top