SimpleCursorTreeAdapter for ExpandableListView
How does the cursor nee开发者_开发百科d to be formatted so that so that I get categories and their children to display correctly. How will the adapter discern between what are categories and what are children?
The initial Cursor just needs the parent items. Here I usually use a Cursor that gives me distinct values.
You need to extend SimpleCursorTreeAdapter and overwrite getChildrenCursor(). Here I use the selected distinct value to return a Cursor that contains all rows of that type.
Simply said, you need a cursor for the parent value and one for every child. Most of the time the child cursor is the same with a where clause for the selected parent.
精彩评论