Reputation: 1338
I want to get the initialized CursorLoader
instance from LoaderManager
like this:
CursorLoader loader = (CursorLoader) getLoaderManager().getLoader(0);
But the compiler gives me this error:
Cannot cast from Loader<Object> to CursorLoader
I could hold the CursorLoader
instance when it is created, but I'd rather let LoaderManager
maintain it. So any idea to fix this?
I am using compatibility-library-v4.
Upvotes: 1
Views: 1918
Reputation: 1338
It needs to be converted twice:
Loader<Cursor> loader = getLoaderManager().getLoader(0);
CursorLoader cloader = (CursorLoader) loader;
Upvotes: 12