简体   繁体   中英

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+

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

try with this

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM