LoaderManager does not accept 'this'

﹥>﹥吖頭↗ 提交于 2019-12-04 09:44:57

That method expects LoaderCallbacks as an argument.

Your Activity needs to implement the LoaderCallbacks interface. OR you provide an anonymous implementation of that interface like:

    LoaderManager.LoaderCallbacks callbacks = new LoaderManager.LoaderCallbacks() {
        @Override
        public Loader onCreateLoader(int id, Bundle args) {
            return null;
        }

        @Override
        public void onLoadFinished(Loader loader, Object data) {

        }

        @Override
        public void onLoaderReset(Loader loader) {

        }

  getLoaderManager().initLoader(LOADER_MANAGER_ID, null, callback);

Implementation of the interface methods is up to you though, this code won't work right away.

兰坡阳

Change: getLoaderManager() to getSupportLoaderManager();
Like this:
getLoaderManager().initLoader(ID_FAVORITE_METAINFO_LOADER, args, this);
To
getSupportLoaderManager().initLoader(ID_FAVORITE_METAINFO_LOADER, args, this);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!