0

I have List View that is filled with data from server and when user swipe bot it add another 8 items to list but problem is that scroll go to top every time when user scroll. How can i set scroll to got to last item in list. I tried with listview.smoothScrollToPosition(merchantadapter.getcount()); but it's not working

Here is my implementation of refresh method

  swipyRefreshLayout = (SwipyRefreshLayout) rootView.findViewById(R.id.refreshsales);
    swipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh(SwipyRefreshLayoutDirection direction) {
            if (direction == SwipyRefreshLayoutDirection.BOTTOM) {
                index++;

                swipyRefreshLayout.setRefreshing(false);
                showlist();



            progressBar.dismiss();


            }
        }
    });

    showlist();
    return rootView;
}
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58

2 Answers2

0

Easily add this to the XML of your list view :

android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"
Chris Sherlock
  • 931
  • 5
  • 19
0

I manage to create solution for my problem I will post it here for anyone else who might need it:

 int firstitemposition=0;
 int currentposition= list.getFirstVisiblePosition();
 list.setSelectionFromTop(currentposition,firstitemposition);