0

I am trying to implement a dynamically loaded ListView (includes scrolling, fetching and dynamically loading content onto the screen).

One way to implement this is by using the onScreenScrollListener(), but is there any other efficient way of implementing this, since the onScreen() event is generated everytime the top list item goes out of focus from the screen on the top.

Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50
user3293692
  • 567
  • 1
  • 5
  • 14
  • you can follow [this][1] link and [this][2] link here..,maybe it helps you. [1]: http://stackoverflow.com/questions/13761639/android-dynamic-loading-list-view-onscrolllistener-issues [2]: http://stackoverflow.com/questions/16398921/dynamic-listview-adding-load-more-items-at-the-end-of-scroll – rajshree Feb 12 '14 at 13:25
  • Dear, your requirement `(i.e. includes scrolling, fetching and dynamically loading content onto the screen)` is already handled by ListView, by default. ListView only needs data-list (data-set) to be displayed. – Chintan Soni Feb 12 '14 at 13:26
  • sure: use a AbstractWindowedCursor and some CursorAdapter adapter – pskink Feb 12 '14 at 13:28

2 Answers2

0

I suppose what you are looking for is pagination for ListView items (loading of next page items when scrolled to some point near the end of the list)

I suggest you check out AmazingListView, it's not very easy to use but it is a useful component not only providing pagination but also providing iPhone like Section Header Implementation

Saro Taşciyan
  • 5,210
  • 5
  • 31
  • 50
0

Set the AbsListView.OnScrollListener on your list view or grid view and implement the methods with something like this:

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
  if (((scrollState == SCROLL_STATE_FLING) || (scrollState == SCROLL_STATE_IDLE)) && isShowNextPage()) {
    loadNextPage();
  }
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
  setShowNextPage(firstVisibleItem + visibleItemCount > (totalItemCount - pagingTolerance));
}
Thomas R.
  • 7,988
  • 3
  • 30
  • 39