Andrew
Andrew

Reputation: 21076

Scroll ListView to show footer

I have a ListView which displays search results. When a search is being performed, I add a footer to the ListView which indicates that a search is in progress. I'd like to programmatically scroll my ListView to the bottom so the footer is visible to the user. Ideas?

My app is targeted to 2.1+

Upvotes: 3

Views: 2925

Answers (2)

Go Goal
Go Goal

Reputation: 111

try with this

lv.post(new Runnable() {
                @Override
                public void run() {

                    lv.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
                    lv.setStackFromBottom(true);
                }
            });

Upvotes: 2

Binoy Babu
Binoy Babu

Reputation: 17119

Use this method to scroll the ListView to bottom.

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

Taken from Listview Scroll to the end of the list after updating the list

Upvotes: 3

Related Questions