getLoaderManager().initLoader() doesn't accept 'this' as argument though the class (ListFragment) implements LoaderManager.LoaderCallbacks

后端 未结 19 1661
无人共我
无人共我 2020-12-07 16:19

I\'m having trouble following a guide on using SQLite in Android. I\'m using a ListFragment instead of a ListActivity(as in the example), so I have

19条回答
  •  醉话见心
    2020-12-07 16:48

    I am using minSDK 27 and had this same issue, I tried to cast like @Dexter suggest, but that gave an error saying cannot be cast to android.app.LoaderManager$LoaderCallbacks, so I then tried to use different import statements and this worked. I commented out the v4 versions and this is what I have now and the app is working:

    //import android.support.v4.app.LoaderManager;
    import android.app.LoaderManager;
    import android.support.v4.app.NavUtils;
    //import android.support.v4.content.CursorLoader;
    import android.content.CursorLoader;
    //import android.support.v4.content.Loader;
    //import android.content.Loader;
    

    Not quite sure when/how the v4 versions were imported.

提交回复
热议问题