How to create custom groupIndicator for ExpandableListView group

Published by Igor Khrupin on

Here is tutorial How to create custon groupIndicator for ExpandableListView in Andriod.
Here is screenshot:

To do it you need:

1. Create 9-patch images for normal and expanded state
2. Create selector with this 9-patch images

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_expanded="true" android:drawable="@drawable/group_indicator_expanded" />
    <item android:drawable="@drawable/group_indicator" />
</selector>

3. Set this selector as groupIndicator for ExpandableListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <ExpandableListView
        android:id="@+id/expandableListView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:groupIndicator="@drawable/group_indicator_selector" >
    </ExpandableListView>
</LinearLayout>

That’s all.

Here you can download the source code of sample Android project

Download it from github

1 Comment

blackhat unlimited proxies · 22 August, 2012 at 14:03

Helpful information. Lucky me I discovered your web site accidentally, and I am surprised why this accident did not came about earlier! I bookmarked it.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.