I want to implement the load more functionality inside my Staggered gridview. I have tried some lines of code for it like using addOnScrollListener
but did not
Actually i was using the NestedScrollView
which was the parent view
of my Staggered recycleview
.Therefore addOnScrollListener
listener and setOnScrollChangeListener
was not working in it..
I have used setOnScrollChangeListener
in a NestedScrollView
and it worked fine. Check my below solution for it:-
NestedScrollView myNestedScroll= (NestedScrollView) findViewById(R.id.myNestedScroll);
myNestedScroll.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY > oldScrollY) {
Log.i(TAG, "Scroll DOWN");
}
if (scrollY < oldScrollY) {
Log.i(TAG, "Scroll UP");
}
if (scrollY == 0) {
Log.i(TAG, "TOP SCROLL");
}
if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
Log.i(TAG, "BOTTOM SCROLL");
}
}
});