Hello everyone.
I'm trying to do simple app that has a listview, listview is populated with info from json file.
20 items downloaded at a time. And when user is scrolling to the bottom next 20 items are loaded.
Problem is when my app loads next 20 items the scrollbar jumps to the top, so i need to scroll all the way down to load next 20. What I would like it to do is to stay on the same spot, where it was before loading(respectively, what i mean is the scroll bar will become shorter and the same list items should be visible). I hope you understand what I wish to achieve.
Please help me.
Thank you :)

Inside setOnScrollListener ...

{
public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                // TODO Auto-generated method stub
                if(firstVisibleItem+visibleItemCount>=totalItemCount){
                    x = firstVisibleItem;
                    int index = lv.getFirstVisiblePosition();
                    View v = lv.getChildAt(0);
                    int top = (v == null) ? 0 : v.getTop();
                    listLoader();// loading 20 items more
                    lv.setSelectionFromTop(index, top);
                }
            }
}

using

.notifyDataSetChanged();

to make changes visible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.