0

我一直在尝试使用光标加载器。我开始关注本教程 http://responsiveandroid.com/2012/03/19/using-an-android-cursor-loader-with-a-content-provider.html但可以不明白。教程让我陷入混乱。

据我所知,cursorloader 是一个适配器,适配器的工作是去内容提供商获取数据,然后将数据放入查看。

内容解析器是做什么的?

Android 文档说 SimpleCursorAdapter 已被贬值并说要使用光标适配器,这是我正在谈论的教程 http://responsiveandroid.com/2012/03/19/using-an-android-cursor-loader-with-a-content -provider.html

在这里,他同时使用了 simplecursoradapter 和 cursor loader。为什么会这样?谁能解释一下,如何使用游标加载器?

4

2 回答 2

2

你把两个不同的东西混为一谈。

游标加载器从数据源获取数据并将其加载到游标中,然后管理游标。游标基本上是一种内存数据存储结构。

适配器从光标(或数组或列表)中获取数据并将其放入您的显示布局中以供查看。

于 2012-09-10T17:52:19.467 回答
0

我认为您仍然可以使用 SimpleCursorAdapter。查看文档,看起来旧的构造函数已被弃用,但您可以使用另一个构造函数,即:

SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) 标准构造函数。

更多细节在这里:http: //developer.android.com/reference/android/widget/SimpleCursorAdapter.html

于 2012-09-11T08:29:54.827 回答