Android - how can i know when gridview has reached the bottom?
And here is my solution, You may want to simply override the onOverScrolled
method :
@Override
protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
View view = (View) getChildAt(getChildCount()-1);
int diff = (view.getBottom()-(getHeight()+getScrollY()));
if(diff==0) {
//overscroll on bottom
} else {
//overscroll on top
}
}
You can use setOnScrollListener to your GridView.
Here is the code example:
gridView.setOnScrollListener(new OnScrollListener(){
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
{
if(firstVisibleItem + visibleItemCount >= totalItemCount){
// End has been reached
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState){
}
});