转自:http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/
I’ve been writing a bit more Android code, and came upon the need to write a custom CursorAdapter for aListView, as the way I wanted to display data from a Cursor was dependent on relationships between different fields of the database.
Of the problems I encountered, the most obvious was when I tried to inflate views using View.inflate(), and found I would get the following error:
After a bit of rummaging around, I found that the following bit of code would work when attached to a ListView using setAdapter().
The above example code doesn’t actually require a CursorAdapter, it would easily be implemented using aSimpleCursorAdapter, but it serves to show the idea. Basicly, get a LayoutInflater from the context, and use the version of inflate() that does not attach to the root view.