带光标适配器的异步列表视图
我有一个列表视图,显示来自 sqlite 数据库的数据。起初,我使用了从内容提供程序查询获取 Cursor 的典型代码,然后创建 SimpleCursorAdapter。问题是该数据库可能会变得更大,因此建议使用异步方法。
我读过有关 CursorLoader 和类似内容的内容,但不幸的是我的应用程序需要在 api level 4 上工作,所以我无法使用它。
例如,是否有某种可能的方法通过 AsyncTask 来做到这一点?任何帮助或片段将不胜感激
I have a list view that shows data from a sqlite db. At first I used the typical code of getting a Cursor from a content provider query and then creating a SimpleCursorAdapter. The problem is that this database could get bigger and thus an asynchronous approach would be recommended.
I've read about CursorLoader and similar, but unfortunately my app needs to work on api level 4 so I can't use that.
Would there be some possible way to do this through an AsyncTask for example? Any help or snippet will be highly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CursorAdapter 是正确的选择。
如果您的数据库增长,那么在遇到可扩展性问题之前,您就会遇到可用性问题(200 行太多,无法滚动)。
通过智能地使用查询和过滤来解决 UI 问题,并且不会遇到性能问题。
CursorAdapter is the way to go.
If your database grows, you will run into usability issues (200 rows is too many rows to scroll through) well before you run into scalability issues.
Solve the UI issue through intelligent use of querying and filtering and you won't reach the performance issue.