ExpandableListView
ExpandableListView:
android ExpandableListView – a widget in the android that contains the two-level expandable/collapsible list.
Often used, for example, to display a series of groups while each group contains a list of elements. This way, users can double-click a group name to either expand or minimize the items below it and vice versa.
Example:
// activity_main.xml
<?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"
android:background="#f4f4f4">
<ExpandableListView
android:id="@+id/expandable_listview"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</LinearLayout>
// parent_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/parent_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Parent Text"
android:layout_marginLeft="16dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
// child_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/child_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Child Text"
android:layout_gravity="center" />
</LinearLayout>