Skip to content Skip to sidebar Skip to footer

Continious Scrolling In Recyclerview By Json Request And Adding New Item With Previous

I want to implement endless scrolling in recyclerview by calling new JSON request with increment of page number and adding those result with the previous results. first request sho

Solution 1:

You only have to add your new data to the last position of list movies and everything will work fine. For this-

Create a new List like ArrayList<movie> newListMovies and add your updated data into it. Now add newListMovies into listMovies and notify to adapter. Just like below-

  ArrayList<movie> newListMovies = newArrayList<>();

  // your code..

  listMovieHits.addOnScrollListener(newEndlessRecyclerViewScrollListener(linearLayoutManager) {
        @OverridepublicvoidonLoadMore(int page, int totalItemsCount) {
            loadingMore=true;
            sendJsonRequest();

            intcurrentSize= adapter.getItemCount();
            listMovies.addAll(newListMovies);
            adapter.notifyItemRangeInserted(currentSize, listMovies.size() - 2);
        }
    });

Hope it will help.

Post a Comment for "Continious Scrolling In Recyclerview By Json Request And Adding New Item With Previous"