在 OnCreateLoader 中有一个 id 参数,您可以使用它来更改 CursorLoader。
你可以做类似的事情
onCreateLoader(int id, bundle args) {
switch(id) {
case FETCH_CONTACT_ID: {
//Return CursorLoader for fetching contactID
break;
}
case FETCH_CONTACT_INFO: {
//Return CursorLoader for fetching raw contacts
break;
}
}
}
OnLoadFinished(Loader loader, Cursor c) {
switch(loader.getId()) {
case FETCH_CONTACT_ID: {
//Contact IDs have been fetched, so start fetching raw contact data
//Enter the IDs you want to fetch data for in the bundle which will be passed to onCreateLoader()
mLoaderManager().restartLoader(FETCH_CONTACT_INFO, args);
break;
}
case FETCH_CONTACT_INFO: {
//Raw contact info has been fetched, do whatever you want with it
break;
}
}
}