If you want to do this all via coding, without using a different image, this is how I got this working.
(1) Setting the group indicator to null
(2) Including my custom group indicator in the group Layout.
(3) Having an groupClickListener
that changes the state of you indicator.
Code Snippets :
(1) mListView.setGroupIndicator(null);
(2) Included my indicator in the group layout.
<ImageView
android:id="@+id/help_group_indicator"
android:layout_width="@dimen/help_group_indicator_dimension"
android:layout_height="@dimen/help_group_indicator_dimension"
android:layout_marginTop="@dimen/help_group_indicator_dimension"
android:src="@drawable/down_icon" />
(3)
mListView.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View clickedView, int groupPosition, long rowId) {
ImageView groupIndicator = (ImageView) clickedView.findViewById(R.id.help_group_indicator);
if (parent.isGroupExpanded(groupPosition)) {
parent.collapseGroup(groupPosition);
groupIndicator.setImageResource(R.drawable.down_icon);
} else {
parent.expandGroup(groupPosition);
groupIndicator.setImageResource(R.drawable.up_icon);
}
return true;
}
});