I'm using a ListView with a CursorLoader
to load my records on it. For taht I set the adapter of the ListView with a SimpleCursorAdapter
. I read on the doc that adding an header to the List with addHeaderView(View)
, wrapped my adapter to an HeaderListViewAdapter. Doing this, I'm not able to cast the adapter to a SimpleCursorAdapter
and using swapCursor()
on it when CursorLoader's onLoadFinished
gets called.
Here's the code that's throwing the exception:
((SimpleCursorAdapter)mDrawerListView.getAdapter()).swapCursor(enhancedCursor);
It says that HeaderLsitView cannot be cast to a SimpleCursorAdapter
Is there anyway to disable that wrapping in order to use the swap cursor on my ListView adapter?
Although you get back a HeaderListAdapter
when calling getAdapter()
on your ListView
you can still get the underlying SimpleCursorAdapter
by calling the getWrappedAdapter()
method on the HeaderListAdapter
.