使用 LoaderManager/CursorLoader 不会解决您填充 SimpleCursorAdapter 的问题。但是您当然应该使用它来从 UI 线程中填充您的列表并有效地处理您的活动的配置更改。
以下是如何将 Cursor 列名称映射到每一行的 TextViews:
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(),
R.layout.custom_row,
null,
new String[] { "columnName_1", "columnName_2", "columnName_3" },
new int[] { R.id.txtCol1, R.id.txtCol2, R.id.txtCol3 }, 0);
setListAdapter(adapter);
这会将光标中的 3 列映射到布局文件中的 3 个 TextView
所以你的 res/layout/custom_row.xml 看起来像这样:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/txtCol1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your column 1 text will end up here!" />
<TextView android:id="@+id/txtCol2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your column 2 text will end up here!" />
<TextView android:id="@+id/txtCol3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your column 3 text will end up here!" />
</LinearLayout>
在现实世界中……您可能会发现使用 TableLayout 的效果会更好。
对于 CursorLoader,看看http://developer.android.com/guide/components/loaders.html
他们提供了一个很好的例子,说明你需要为 CursorAdapters 使用 CursorLoader 和 LoaderManager。
希望有帮助!