嗨,我是新来的,也是android的初学者,我正在制作一个名为“contactsLoader”的LoadManager,并在游标中进行回调
private LoaderManager.LoaderCallbacks<Cursor> contactsLoader =
new LoaderManager.LoaderCallbacks<Cursor>() {
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
String[] projectionFields = new String[]{
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.PHOTO_URI
};
CursorLoader cursorLoader = new CursorLoader(MainActivity.this,
ContactsContract.Contacts.CONTENT_URI,
projectionFields,
null,
null,
null);
return cursorLoader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
adapter.swapCursor(data);
}
@Override
public void onLoaderReset(Loader<Cursor> loader) {
adapter.swapCursor(null);
}
};
问题是我每次调用函数getSupportLoaderManager()。initLoader()
private void loadingContacts() {
Log.d(DEBUG,"We have permission to load the contacts");
getSupportLoaderManager().initLoader(CONTACT_LOADER_ID,new Bundle(),contactsLoader);
}
出现此错误:
Wrong 3rd argument "contactsLoader". Found: 'android.app.LoaderManager.LoaderCallbacks<android.database.Cursor>', required: 'android.support.v4.app.LoaderManager.LoaderCallbacks<java.lang.Object>'
我试图通过这些链接了解问题是什么LoaderManager 和Loaders,但我找不到解决方案