views:

16

answers:

1

I have got list that is filled with data from internet.

Datas are downloaded in chunks. At the end of the list next portion of data is downloaded and added to the list.

I'm detecting list end with help of onScrollListner:

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (view.getAdapter() != null && ((firstVisibleItem + visibleItemCount) >= totalItemCount) && totalItemCount != mPrevTotalItemCount) {
        Log.v(TAG, "onListEnd, extending list");
        mPrevTotalItemCount = totalItemCount;
        addMoreData();
    }
}

I would like to addLoading... row when datas are being downloaded. Something similar to Gmail loading row at the end of the list.

I know that I can hack adapter.getCount() to return size + 1 and force adapter.getView to display loading... at the end of the list.

How can I do that in more elegant way?

+1  A: 

How can I do that in more elegant way?

"Elegance", like beauty, lies in the eye of the beholder. Only you know what you think is elegant, just as all we know is what we think is elegant, and our respective definitions may not align.

FWIW, here is my approach to your problem.

CommonsWare