Recently I was trying to configure the icons of an ExpandableListView. As many people would do, I was trying to replace the default icons for the minimized and maximized states. As it appears, doing this basic thing it's not that straightforward as one would expect/guess. There are not many examples in the forums either (at least I couldn't find one). I would like to share a code excerpt which shows the steps for replacing the default icons in an ExpandableListView. Please beware that the code excerpt of this discussion has been pruned a lot, to show only the steps relevant for replacing the default icons. Hope that this example will be useful for people who are new in Android and who wish to work with ExpandableListViews.
Here is the explanation:
Step-1: You need two icons under <YourCodeBase>\res\drawable. Let's say that these icons are my_icon_min.png and my_icon_max.png.
Step-2: The way to override the default icons of an ExpandableListView lies in creating a Drawable object which has states (minimized and maximized, or expanded and collapsed), and set this object as the group indicator of your ExpandableListView. We need a way for creating the needed Drawable object with states. One decent way of doing this is through an XML file. Android SDK provides an example XML file for this purpose. Under Windows for Android-1.5 the location is android-sdk-windows\platforms\android-1.5\data\res\drawable\expander_group.xml. Since you're interested in replacing the default icons, probably you'll need to copy this file under <YourCodeBase>\res\drawable, edit it and put in the names of your icons (my_icon_min and my_icon_max). See below:
Step-3: Next comes the coding part. Below is a super simple example: