最好使用光标适配器或阵列适配器 [英] Better to use Cursor adapter or Array adapter

查看:223
本文介绍了最好使用光标适配器或阵列适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大约100个​​存储在其中需要根据基于类的,每周的基础,下周,下个月,由于上日程等等...

i have around 100's of schedules stored in database which needs to display them based on Listview based on requirements like, weekly basis, next week, next month, over due schedules etc...

这是好上加载启动应用程序的所有日程,并显示他们根据阵列适配器选项用户选择(每周,过期,每月等)。或者在运行时使用查询,获取从数据库的结果,并使用cusor使用cusoradapter上加载列表视图中的数据?

Is it good to load all the schedules on launch of application and show them based on the option user chooses (Weekly, overdue, monthly etc...) in array adapter. Or at run time use the query, fetch the results from DB and use the cusor to load the data on listview using cusoradapter?.

哪种方法effeciant?我觉得总是查询DB是expesive操作?真有这回事?

Which method is effeciant?, i feel querying the DB always is expesive operation? is it really true?.

推荐答案

在你的情况的CursorAdapter 更合适时,有一个数据库,因为它不会加载的所有记录为 ArrayAdapter 。它只会加载可见的记录。 HOR你是记录查询。这里是<一个文档href=\"http://developer.android.com/reference/android/widget/CursorAdapter.html\">CursorAdapter.

In your case CursorAdapter is more appropriate when there is a database because it does not load all the records as ArrayAdapter. It loads only the visible records. hor the records you are query for. here is the documentation for CursorAdapter.

适配器,从游标公开数据到ListView控件。

Adapter that exposes data from a Cursor to a ListView widget.

光标必须包含一个名为_id列或本级将无法工作。此外,如果合并后的光标在他们的_id列重叠值使用MergeCursor这个类将无法工作。

The Cursor must include a column named "_id" or this class will not work. Additionally, using MergeCursor with this class will not work if the merged Cursors have overlapping values in their "_id" columns.

由于从内容提供商的文档所以它可能不是有用你。

As from the doc of Content provider so it might not useful for you.

您不需要提供使用SQLite数据库,如果使用完全是你自己的应用程序中。

You don't need a provider to use an SQLite database if the use is entirely within your own application.

您可以选择的CursorAdapter ArrayAdapter

这篇关于最好使用光标适配器或阵列适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆