Android Expandable ListView Example

Android expandable ListView is a view that shows items in a vertically scrolling two-level list. It is used to group list data by categories. It expands and collapses when the user touch group list. In this tutorial, you will learn to implement ExpandableListView in android application.

If you are not familiar with android list view and grid view, please follow these tutorials first Simple Android ListView Tutorial with Example, ListView with Text and Image, Simple Android GridView Example.

Custom Android ListView Example
Start New Activity from Android ListView onItemClick
Parallax Header with Android ListView Example

Android Example: Expandable ListView Tutorial with Example

Let’s start new android project with the project name Android Expandable ListView to implement expandable list view in your application.

Open XML layout file and add an ExpandableListView with id android:list and an Toolbar widget with v7 support library with android:id="@+id/toolbar", android:layout_width="match_parent", android:layout_height="58dp”, android:background="?attr/colorPrimary", android:minHeight="?attr/actionBarSize" attributes. Following is the complete content of XML layout file.


Now open you java activity file and extend your activity to ExpandableListActivity. Define variable for ExpandableListAdapter, ExpandableListView and Toolbar. Following is the complete code of java activity file.


Android Example: Expandable ListView Tutorial with Example

That’s it. Run your Android Expandable ListView Example application and click on any of the listview group item, the list will expand and you will see sub items of listview which will look like above screenshot.
UI 2926073845059823646
Home item