문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top