Android ExpandableListView - handling parents with no children
I have a ragged hierarchy of parents and children. Some p开发者_开发百科arents have 5 children, while others have 0 children.
The expandableListView displays the "Expand/Collapse" icon even if there are no children.
Is there a way to hide the icon for only those Parents (rows) that have no children? I still want to show the row of the Parents with no children, and allow a user to click on them, but the "Expand/Collapse" icon is confusing.
Another site suggests that you can set a drawable with state "empty" for the Child Indicator.
Have a look here: Expandable List Indicator
- http://developer.android.com/reference/android/widget/ExpandableListView.html#setGroupIndicator%28android.graphics.drawable.Drawable%29
- http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html
I used a small trick, making a group indicator transparent:
android:groupIndicator="@android:color/transparent"
The description is in this site:
http://mylifewithandroid.blogspot.com/2011/06/hiding-group-indicator-for-empty-groups.html
精彩评论