Question

I'm using loaders in a fragmnet. I've implemented LoaderManager.LoaderCallbacks<Cursor> but I'm still getting the error "The method initLoader(int,Bundle,LoaderManager.LoaderCallbacks<D>) in the type LoaderManager is not applicable for the arguments (int, null, Details)"

    package com.example.ms;

    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v4.app.LoaderManager.LoaderCallbacks;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.TextView;
    import android.app.LoaderManager;
    import android.content.Loader;
    import android.database.Cursor;
    import android.support.v4.content.CursorLoader;
    import android.support.v4.widget.CursorAdapter;


 public class Details extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
private static final int LIST_ID =0;
String University_name;
Long id;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        // Inflate the layout for this fragment

    View v= inflater.inflate(R.layout.details, container, false);
    TextView Name=(TextView)v.findViewById(R.id.university_name);
    Name.setText(University_name);
}



    public void onCreate(Bundle savedInstanceState)
     {  TaskList tl=(TaskList)getActivity();
        Bundle bundle=tl.sendData();
        University_name=bundle.getString("UniName");
        id=bundle.getLong("id");
        getLoaderManager().initLoader(LIST_ID, null,this);



             }
    @Override
    public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public void onLoadFinished(Loader<Cursor> arg0, Cursor arg1) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onLoaderReset(Loader<Cursor> arg0) {
        // TODO Auto-generated method stub

    }

My code is not complete, I'm yet to implement the loader methods

Was it helpful?

Solution

you have to use getSupportLoaderManager() method instead of getLoaderManager

OTHER TIPS

I used getSupportLoadermanager() ,but still there was an error shown. So I implemented the LoaderManager in my FragmentActivity class and passed the data I retrieved from the database to the Fragment through a bundle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top