Hello,
You could implement this feature by listening to scrolling.
For RecyclerView, DotNet Android is no different from Android native, so you need to refer to the Android native documentation.
In .NET, you could implement a listener at the bottom of the scroll using the following code.
recyclerView.AddOnScrollListener(new MyOnScrollingListener());
public class MyOnScrollingListener : RecyclerView.OnScrollListener
{
public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
{
base.OnScrollStateChanged(recyclerView, newState);
GridLayoutManager gm = (GridLayoutManager)recyclerView.GetLayoutManager();
int totalItemCount = recyclerView.GetAdapter().ItemCount;
int lastVisibleItemPosition = gm.FindLastVisibleItemPosition(); //Get the coordinates of the bottommost element
int visibleItemCount = recyclerView.ChildCount;
if (newState == RecyclerView.ScrollStateIdle
&& lastVisibleItemPosition == totalItemCount - 1
&& visibleItemCount > 0)
{
// load more
}
}
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.