我一直在尝试使用游标加载器。我开始关注本教程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和游标加载器。为什么?任何人都可以解释一下,如何使用游标加载器?
答案 0 :(得分:2)
你正在混淆两件事。
游标加载器从数据源获取数据并将其加载到游标中然后管理游标。游标基本上是内存数据存储结构。
适配器从光标(或数组或列表)中获取数据并放入要显示的显示布局中。
答案 1 :(得分:0)
我认为你仍然可以使用SimpleCursorAdapter。查看文档,看起来旧的构造函数已被弃用,但您可以使用另一个构造函数:
SimpleCursorAdapter(Context context,int layout,Cursor c,String [] from,int [] to,int flags) 标准构造函数。
此处有更多详情: http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html