来自光标的列表视图(没有加载器)
SimpleCursorAdapter 适配器 = 新的 SimpleCursorAdapter(
this, // The Activity context
R.layout.list_item, // Points to the XML for a list item
cursor, // Cursor that contains the data to display
dataColumns, // Bind the data in column "text_column"...
viewIDs // ...to the TextView with id "R.id.text_view"
);
来自光标的列表视图(使用加载器)
将数据异步加载到容器(列表视图或片段)加载器是最好的方法。
// Initialize the adapter. Note that we pass a "null" Cursor as the
// third argument. We will pass the adapter a Cursor only when the
// data has finished loading for the first time (i.e. when the
// LoaderManager delivers the data to onLoadFinished). Also note
// that we have passed the "0" flag as the last argument. This
// prevents the adapter from registering a ContentObserver for the
// Cursor (the CursorLoader will do this for us!).
mAdapter = new SimpleCursorAdapter(this, R.layout.list_item,
null, dataColumns, viewIDs, 0);
以下 URL 描述了上述内容。
http://www.androiddesignpatterns.com/2012/07/understanding-loadermanager.html