我已经实现了以下代码以将联系人显示为ListView
. MyAdapter
延伸CursorAdapter
。
public class MainActivity extends FragmentActivity implements
LoaderManager.LoaderCallbacks<Cursor>{
private MyAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView lv = (ListView)findViewById(R.id.listView_val);
adapter = new MyAdapter(this, null, 1);
lv.setAdapter(adapter);
.....
getSupportLoaderManager().initLoader(0, null, this);
}
.....
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { ..... } ....}
我想知道的是,adapter
-怎么mAdapter
知道它必须从(调用后可用)cursor
提供的数据中选择数据?CursorLoader
Cursor
onCreateLoader