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
Use LoaderManager Class ti init Loader
We can use
LoaderManager.getInstance(this).initLoader(0,null,this);
instead of
getLoaderManager().initLoader(PET_LOADER, null, this);