Group items in a ListActivity
I have a super simple ActivityList, say a scoll list with all countries. Now开发者_如何学JAVA, I would like to group the countries by continent like:
- Azia
- China
- India
- Europe
- France
- Greece
The Android Contacts application has a similar behavior (the A, B, C,.. groups for your contacts). I played with cwac-merge but it doesn't have the same behavior (groups don't stick at the top when you scroll for example).
Is there a simple way to do this on Android?
Thanks for helping out a fellow programmer who tries to learn how Android works.
You might want to look at this project AmazingListView. The source code for it and also source for a demo is available.
If you only need 2-level lists, then use ExpandableListView. You can find examples for it in the ApiDemos I believe.
精彩评论