I have about 32 entries in json, I use RecyclerView to show them, and I implemented OnScrollListener (...)
Question
I started work, I extracted all 32 records, now when I scroll, why do I get the same 32 records again and again, whenever I scroll, here is my implementation of OnScrollListener ()
public void initializeOnScrollForRecyclerView() { mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int visibleItemCount = recyclerView.getLayoutManager().getChildCount(); int totalItemCount = recyclerView.getLayoutManager().getItemCount(); int pastVisiblesItems = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition(); if (!isLoading) { if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) { isLoading = true; mPostPresenter.loadPosts(false); } } } }); }
android android-recyclerview appcompat onscrolllistener
Oreo
source share