skip to Main Content

Error using getLoaderManager().initLoader

public class CatalogActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {

    private static final int PET_LOADER = 0;

    PetCursorAdapter mCursorAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_catalog);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
                startActivity(intent);
            }
        });
        ListView petListView = (ListView) findViewById(R.id.list);

        View emptyView = findViewById(R.id.empty_view);
        petListView.setEmptyView(emptyView);

        mCursorAdapter = new PetCursorAdapter(this, null);
        petListView.setAdapter(mCursorAdapter);

        getLoaderManager().initLoader(PET_LOADER, null, this);
    }

enter image description here
This is the image of the problem on Android Studio

2

Answers


  1. Use LoaderManager Class ti init Loader

    LoaderManager.getInstance(this).initLoader(PET_LOADER, null, this);
    
    Login or Signup to reply.
  2. We can use LoaderManager.getInstance(this).initLoader(0,null,this);
    instead of getLoaderManager().initLoader(PET_LOADER, null, this);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search