Android - ListView to load more items when reached end

I have successfully implemented a listView where each row is an object I've created. I have an interface which reads some objects and returns an array of them, which I pass to the adapter constructor. What I want to do is, since the list may be very long, My interface allows to read each time some more items (page 0, page 1...) so I Want, when the user reaches the last row of the list, load the next page and insert it to the listView. What is the proper way of doing so? I actually want the "reach end of list" trigger a callback where I can request for more pages and load them to the list. A bit OT to my main question, But I dont mind using a baseAdapter, both would work, I just dont know what's better for the task.


You can add a footer on the listView which will have a button named LoadMore. Here is a complete tutorial ListView with Load More Button Or you can implement onscrolllistener() and add this listener to your ListView

public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    this.currentFirstVisibleItem = firstVisibleItem;
    this.currentVisibleItemCount = visibleItemCount;

public void onScrollStateChanged(AbsListView view, int scrollState) {
    this.currentScrollState = scrollState;

private void isScrollCompleted() {
    if (this.currentVisibleItemCount > 0 && this.currentScrollState == SCROLL_STATE_IDLE) {
        /*** In this way I detect if there's been a scroll which has completed ***/
        /*** do the work for load more date! ***/
             isLoading = true;

Hope it will help

There is no need to do anything .. In your xml file just add the list view , it will automatically handle itself with a scroll view as no of entries is increased.

Need Your Help

Aspect pointcut to match Annotation property

spring aop aspectj

I'm trying to use Spring AOP with AspectJ support to weave methods with a certain annotation. I know it's easy to do so by using a pointcut @annotation(classname)

Redirect loop when redirecting to mobile theme

php wordpress redirect mobile

I'm having problems with redirecting mobile users to the mobile theme.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.