I have to implement a sort of pagination for a subclass of ListView.
When the user scrolls down the list, the scroll is finished and he views the last row, I have to request next page of data, if any. Same thing for scroll up/first row/previous page.
public class ContactList extends ListView implements OnGestureListener {
GestureDetector gestureDetector;
public ContactList(Context context) {
super(context);
gestureDetector = new GestureDetector(this);
}
//Other ctors here...
}
I then attached a GestureDetector to the ListView, forwarding to it all the touches.
public boolean onTouchEvent(MotionEvent ev) {
return gestureDetector.onTouchEvent(ev);
}
Can I detect in my OnGestureListener.onScroll() if first/last row is visible using getFirst/LastVisiblePosition()?
Maybe this method is called before the scroll occurs?
Thank you for any help.
I think you need to setup
OnScrollListenerfor your ListView and gather positions fromonScrollcallback: