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

后端 未结 19 1621
无人共我
无人共我 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 17:05

    It's late but maybe help some one.
    if you use loader maneger in fragment and you min api is below HONEYCOMB
    you shuld use this imports

    import android.support.v4.app.LoaderManager;
    import android.support.v4.content.CursorLoader;
    import android.support.v4.content.Loader;
    import android.support.v4.widget.CursorAdapter;      
    import android.support.v4.app.Fragment;
    

    and for initiate loader use this code

    getActivity().getSupportLoaderManager().initLoader(/loader stuff*/);
    

    hope this help some one.

提交回复
热议问题