Android - onLoadFinished not called

前端 未结 5 2256
谎友^
谎友^ 2021-02-14 12:03

I am facing an issue with Loader.

I have an Activity, which displays list of records retrieved from local DB. When the activity starts, records are automatically loaded

5条回答
  •  無奈伤痛
    2021-02-14 12:44

    Check the support library.Use this import android.support.v4.app. Don't use android.app.loadermanager.

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

    Initialize part

        LoaderManager mLoaderManager=getSupportLoaderManager(); 
    
          LoaderManager.LoaderCallbacks mCursorLoaderCallbacks=new LoaderManager.LoaderCallbacks() {
                    @Override
                    public Loader onCreateLoader(int id, Bundle cursor) {
                          return new CursorLoader(getActivity(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, COLUMNS_OF_INTEREST, null, null,
                                MediaStore.Video.Media.DATE_ADDED + " DESC");
                    }
                    @Override
                    public void onLoadFinished(Loader loader, Cursor cursor) {
                    }
    
    
                    @Override
                    public void onLoaderReset(Loader loader) {              
                   }
                };
    
      mLoaderManager.initLoader(URL_LOADER_EXTERNAL, null, mCursorLoaderCallbacks);
    

提交回复
热议问题