What is this blue shadow called which apears when the view is pulled after it ends? is there a listener triggered when this appears or goes?
I have implemented https://github.com/maurycyw/StaggeredGridView and I want to load more items when this viewgroup is overscrolled.
It is called as Overscroller.Listview
has built-in support for overscrolling. Check out setOverscrollMode
and related methods setOverscrollHeader
and setOverscrollFooter
. ListView makes use of the overscroll header/footer by overriding AbsListView.onOverscrolled;
if you want different behavior, you can implement it by overriding it yourself.
unfortunately there's no ready library or functionality to achieve that. But there're good open library that you can adapt.
My suggestion is to check SwipeRefreshLayout
, it's on the Android support library.
This ViewGroup support a swipe from the top to give a callback, you probably can adapt it to implement a bottom swipe.
docs: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
source code: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/widget/SwipeRefreshLayout.java
edit:
alternatively, to implement a load more
function with scroll listener is relatively easy, it's just a simple OnScrollListener
with the following code:
private long lastRequestTime = 0;
public void onScroll (AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount){
if (((firstVisibleItem+visibleItemCount) > totalItemCount - 4) &&
(lastRequestTime + 1000 < System.currentTimeMillis())) {
lastRequestTime = System.currentTimeMillis();
// load more ...
}
}
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