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

后端 未结 19 1662
无人共我
无人共我 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:59

    A few things to watch out for (from my recent experience battling with this):

    1. If your minSDK is set to less than 11 (i.e. level 10 for Gingerbread) and you are using the Support Pack for backward compatibility, make sure you use

      getSupportLoaderManager().initLoader(LOADER_ID, null, this);
      
    2. You mentioned this when you said you are using ListFragment, but it bears repeating: Do not extend Activity, otherwise the support package will not work. Instead, extend the FragmentActivity class or the ListFragment class.

    3. For your imports, make sure you are using the correct versions if your minSDK < 11:

       android.support.v4.app.FragmentActivity;
       android.support.v4.app.LoaderManager;
       android.support.v4.content.Loader;
      

    Hope this helps you... or at least someone else...

提交回复
热议问题