3

I have seen the previuos question

import android.app.ListFragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;





public class Myfragment extends ListFragment implements
        LoaderManager.LoaderCallbacks<Cursor> {

    View v;
    private int id = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);



    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        v = inflater.inflate(R.layout.job_layout, container);
        getListView().setAdapter(new Jobs_Adapter());
        return inflater.inflate(R.layout.job_layout, container);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {

        super.onActivityCreated(savedInstanceState);
//      getLoaderManager().initLoader(id, null,
//              (android.app.LoaderManager.LoaderCallbacks<Cursor>) this);
        // Manager().initLoader(0, null,
        // (android.app.LoaderManager.LoaderCallbacks<Cursor>) this);
        getLoaderManager().initLoader(id, null,this);
    }

    @Override
    public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {

        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

    }

}

i have seen all related question all suggesting use of support libraries but what if one doesnt wants to use support libraries and is it recommended?. I am using a stand alone fragment instead of using it inside FragmentActivity

Community
  • 1
  • 1
dreamer1989
  • 1,075
  • 3
  • 12
  • 29
  • Your question is not very clear. Please update your question with what you are trying and the errors you get. – Salem Aug 08 '14 at 16:56
  • @Salem please review the question provided in the link as it is the same problem of using initializing loader but if doesnt uses support library youu get this error The method initLoader(int, Bundle, LoaderManager.LoaderCallbacks) in the type LoaderManager is not applicable for the arguments (int, null, myfragment) all answers suggest use of support library what if i dont want to use them – dreamer1989 Aug 08 '14 at 17:02
  • And you are using ActionBarSherlock? – Salem Aug 08 '14 at 17:10
  • 1
    Replace `android.support.v4.app.LoaderManager` and `android.support.v4.content.Loader` with `android.app.LoaderManager` and `android.content.Loader`. It works? – Salem Aug 08 '14 at 17:28

1 Answers1

4

The problem here is that you are mixing regular/support classes. As you don't want to use support library, just replace

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

with

import android.app.LoaderManager;
import android.content.Loader;
Salem
  • 12,808
  • 4
  • 34
  • 54