Detect Scroll Up & Scroll down in ListView
I have the following requirement:
i> At first, data for page no: 2 is fetched from the server & the items are populated in a ListView.
Considering that both the prev page & next page are available in a scenario, the following code has been added:
if(prevPageNo > 0){
mListViewActual.setOnScrollListener(this);
}
if(nextPageNo > 0){
mListViewActual.setOnScrollListener(this);
}
What conditions should I put to detect scroll up & scroll down on the following methods:
i> void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
ii> void onScrollStateChanged(AbsListView view, int scrollState)
After the action: scroll up & scroll down is detected , accordingly a service will be called with either the prev page no or next page no , to fetch the items to be populated in the Listview.
Any inputs will be helpful.
Gone through the following links but its not returning the correct scroll up / scroll down action:
http://stackoverflow.com/questions/9629872/how-to-detect-if-a-listview-is-scrolling-up-or-down-in-android
http://stackoverflow.com/questions/12114963/detecting-the-scrolling-direction-in-the-adapter-up-down
.
stackoverflow.comm
No comments:
Post a Comment