Han
Han

Reputation: 650

How to keep listview showing the bottom items as I scroll an endless list?

I am having this trouble when developing an endless listview..As I scroll down to the bottom I fetch more data and update the listview, however it goes back to the top of the list. What else to I need to make the list load new item but not changing the position? Please help, Thx!

    streamLV.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;
            if(loadMore){
                    dosomething to get the items..then
                    lvAdapter.addItem(item);
                }
                streamLV.setAdapter(lvAdapter);
            }       
        }
    });     

Upvotes: 0

Views: 1182

Answers (1)

dmon
dmon

Reputation: 30168

Try calling lvAdapter.notifyDatasetChanged() instead of setting it again on the ListView (instead of calling streamLV.setAdapter()).

Upvotes: 3

Related Questions