I created Recycler View Grid. And I want realize pagination. But I do not understand how do it. I Found one answer enter link description here
But it not work for me. I have not method mLayoutManager.findFirstVisibleItemPosition();
in my LayOutManager. And method mRecyclerView.setOnScrollListener
is deprecated. How can I realize pagination in Recycler View Grid?
A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as well as determining the policy for when to recycle item views that are no longer visible to the user.
Late answer but you can try this..and It works perfectly
allMovie_recycler_view.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (dy > 0) {
val layoutManager = allMovie_recycler_view.layoutManager as GridLayoutManager
val visibleItemCount = layoutManager.findLastCompletelyVisibleItemPosition()+1
if (visibleItemCount == layoutManager.itemCount){
//Load more data
}
}
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With