Reputation: 213
I have an expandable list
so two question
(I've seen somme similar question but never found the answer) How do I hide the arrow ( group indicator) when there's no children
I tried to do it in the adapter
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) {
if(getChildrenCount(groupPosition)==0) {
// how do i hide the group indicator ?
}
But I'm stuck So, how can modify the group indicator for empty groups ?
How to have different behavior when you click on the arrow (expands the group) vs you click on the title of the group (go to an activity)
Upvotes: 6
Views: 4799
Reputation: 11141
Just create a group_indicator.xml file in drawable folder to specify the parent state using the code,
<item android:state_empty="true" android:drawable="@android:color/transparent"></item>
<item android:state_expanded="true" android:drawable="@drawable/arrowdown"></item>
<item android:drawable="@drawable/arrowright"></item>
Then specify this style in the Expandable list view using the code,
<ExpandableListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:groupIndicator="@drawable/group_indicator"
android:layout_weight="1" >
</ExpandableListView>
Upvotes: 2
Reputation: 73484
Upvotes: 4