开发者

Loading... row at the end of the list - during data download

开发者 https://www.devze.com 2023-01-09 14:47 出处:网络
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 downloadedand added to the list.

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 loadin开发者_运维技巧g... at the end of the list.

How can I do that in more elegant way?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消