the_big_blackbox
the_big_blackbox

Reputation: 1196

LoaderManager LoaderCallback Object

Hi please can someone assist I am trying to create a basic loader. All the documentation that I have seen around Loaders involves the following:

public class MyActivity extends Activity 
                    implements LoaderManager.LoaderCallbacks<Cursor> {

    private static final int CONTACTS_LOADER_ID = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

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

However I always receive an error on the "this" in initLoader, wrong 3rd argument required android.app.LoaderManager. LoaderCallbacks.

Upvotes: 0

Views: 197

Answers (1)

Blackbelt
Blackbelt

Reputation: 157467

However I always receive an error on the "this" in initLoader, wrong 3rd argument required android.app.LoaderManager. LoaderCallbacks.

then you have imported LoaderManager.LoaderCallbacks from the support library. You can either change the import to the native support, or extend AppCompatActivity instead of Activity and use getSupportLoaderManager()

Upvotes: 1

Related Questions