开发者

How to properly download and update ListView progressively?

Currently I have a service that downloads about 500 records of somewhat complex data, when the user request a refresh or the cached data expires, the service downloads the data and caches it into a database. In the activity where the list is shown I'm listening for broadcasts from the service about the download progress. Every time I get a progress status I run:

mAdapter.getCursor().requery();

I see my data progressively filling the ListView as its downloading which is nice... But I have two big concerns.

  1. My solution seems very complex and 开发者_如何学JAVAdirty.
  2. This solution won't work on Android 3.0 and later.

I'm looking for feedback on how to better approach this. There has to be a better way.


If you're concerned about the use of requery() and an alternative for Android 3.0, see the deprecation note in the CursorAdaptor documentation, which explains using LoaderManager and CursorLoader as an alternative.

Based on your explanation of the requirements of your app, the way you're doing it is probably the most idiomatic approach, and I wouldn't really call it "dirty". Seems straight forward to me.


I would suggest providing a loading screen when the user refreshed, instead of progressively populating your list. This seems cleaner to me. At any rate you will have to requery the cursor whether it be progressively or at the end, so not sure which part you think could use improvement.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜