onscrolllistener
RecyclerView ScrollListener inside NestedScrollView
To achieve endless scrolling for recycler view which is under NestedScrollView, you can use “NestedScrollView.OnScrollChangeListener” nestedScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> { if(v.getChildAt(v.getChildCount() – 1) != null) { if ((scrollY >= (v.getChildAt(v.getChildCount() – 1).getMeasuredHeight() – v.getMeasuredHeight())) && scrollY > oldScrollY) { //code to fetch more data for endless scrolling } } }); Here v.getChildCount() … Read more
How to implement setOnScrollListener in RecyclerView
Activity Class with recylcerview in xml layout file public class WallpaperActivity extends AppCompatActivity implements OnTaskCompleted { private static final String TAG = “WallpaperActivity”; private Toolbar toolbar; private RecyclerView mRecyclerView; private WallPaperDataAdapter mAdapter; private LinearLayoutManager mLayoutManager; // to keep track which pages loaded and next pages to load public static int pageNumber; private List<WallPaper> wallpaperImagesList; protected … Read more
RecyclerView scrolled UP/DOWN listener
The accepted answer works fine, but @MaciejPigulski gave more clear and neat solution in the comment below. I just putting it as an answer here. Here’s my working code. mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (dy > 0) { // Scrolling up } else … Read more
Android setOnScrollListener on RecyclerView deprecated
addOnScrollListener(OnScrollListener) means you can add more than one listener to a RecyclerView. removeOnScrollListener(OnScrollListener) means you can remove one of the listeners that attached to a specific RecyclerView. If the arg was set null, it equals to clearOnScrollListeners() method. And, clearOnScrollListeners() let you remove all the listener from a RecyclerView.
How to implement endless list with RecyclerView?
Thanks to @Kushal and this is how I implemented it private boolean loading = true; int pastVisiblesItems, visibleItemCount, totalItemCount; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { if (dy > 0) { //check for scroll down visibleItemCount = mLayoutManager.getChildCount(); totalItemCount = mLayoutManager.getItemCount(); pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition(); if (loading) { if ((visibleItemCount … Read more