androidinfinite-scrollendlessscroll

when load new page endless recycler go to first position


i have recycler and use the endless recycler(Link) for load data from server with volley i have a problem! when load next page for example load page 2 and when recycler update , recycler refresh and goes to first position and i do not want goes to first i want show continuation of the list. please help me?!

my code :

recyclerView.addOnScrollListener(new EndlessRecyclerOnScrollListener(manager) {
  @Override
  public void onLoadMore(int current_page) {
    int lastFirstVisiblePosition = ((GridLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
    ((GridLayoutManager) recyclerView.getLayoutManager()).scrollToPosition(lastFirstVisiblePosition);
    LoadMore(current_page);

  }
});

Solution

  • It is because you set adapter after success of volley response. before volley response, you have just add response data in list and notify adapter after success of volley response.

    In sort you don't have to set adapter every time after response. you have to just add response in list and just notify adapter.