Android APIs
public class

SimpleExpandableListAdapter

extends BaseExpandableListAdapter
java.lang.Object
   ↳ android.widget.BaseExpandableListAdapter
     ↳ android.widget.SimpleExpandableListAdapter

Class Overview

An easy adapter to map static data to group and child views defined in an XML file. You can separately specify the data backing the group as a List of Maps. Each entry in the ArrayList corresponds to one group in the expandable list. The Maps contain the data for each row. You also specify an XML file that defines the views used to display a group, and a mapping from keys in the Map to specific views. This process is similar for a child, except it is one-level deeper so the data backing is specified as a List>, where the first List corresponds to the group of the child, the second List corresponds to the position of the child within the group, and finally the Map holds the data for that particular child.

Summary

Public Constructors
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int groupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo)
Constructor
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo)
Constructor
SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo)
Constructor
Public Methods
Object getChild(int groupPosition, int childPosition)
long getChildId(int groupPosition, int childPosition)
View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
int getChildrenCount(int groupPosition)
Object getGroup(int groupPosition)
int getGroupCount()
long getGroupId(int groupPosition)
View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
boolean hasStableIds()
boolean isChildSelectable(int groupPosition, int childPosition)
View newChildView(boolean isLastChild, ViewGroup parent)
Instantiates a new View for a child.
View newGroupView(boolean isExpanded, ViewGroup parent)
Instantiates a new View for a group.
[Expand]
Inherited Methods
From class android.widget.BaseExpandableListAdapter
From class java.lang.Object
From interface android.widget.ExpandableListAdapter
From interface android.widget.HeterogeneousExpandableList

Public Constructors

public SimpleExpandableListAdapter (Context context, List<? extends Map<String, ?>> groupData, int groupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo)

Added in API level 1

Constructor

Parameters
context The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running
groupData A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom"
groupLayout resource identifier of a view layout that defines the views for a group. The layout file should include at least those named views defined in "groupTo"
groupFrom A list of keys that will be fetched from the Map associated with each group.
groupTo The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter.
childData A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom"
childLayout resource identifier of a view layout that defines the views for a child. The layout file should include at least those named views defined in "childTo"
childFrom A list of keys that will be fetched from the Map associated with each child.
childTo The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter.

public SimpleExpandableListAdapter (Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, String[] childFrom, int[] childTo)

Added in API level 1

Constructor

Parameters
context The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running
groupData A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom"
expandedGroupLayout resource identifier of a view layout that defines the views for an expanded group. The layout file should include at least those named views defined in "groupTo"
collapsedGroupLayout resource identifier of a view layout that defines the views for a collapsed group. The layout file should include at least those named views defined in "groupTo"
groupFrom A list of keys that will be fetched from the Map associated with each group.
groupTo The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter.
childData A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom"
childLayout resource identifier of a view layout that defines the views for a child. The layout file should include at least those named views defined in "childTo"
childFrom A list of keys that will be fetched from the Map associated with each child.
childTo The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter.

public SimpleExpandableListAdapter (Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, int lastChildLayout, String[] childFrom, int[] childTo)

Added in API level 1

Constructor

Parameters
context The context where the ExpandableListView associated with this SimpleExpandableListAdapter is running
groupData A List of Maps. Each entry in the List corresponds to one group in the list. The Maps contain the data for each group, and should include all the entries specified in "groupFrom"
expandedGroupLayout resource identifier of a view layout that defines the views for an expanded group. The layout file should include at least those named views defined in "groupTo"
collapsedGroupLayout resource identifier of a view layout that defines the views for a collapsed group. The layout file should include at least those named views defined in "groupTo"
groupFrom A list of keys that will be fetched from the Map associated with each group.
groupTo The group views that should display column in the "groupFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the groupFrom parameter.
childData A List of List of Maps. Each entry in the outer List corresponds to a group (index by group position), each entry in the inner List corresponds to a child within the group (index by child position), and the Map corresponds to the data for a child (index by values in the childFrom array). The Map contains the data for each child, and should include all the entries specified in "childFrom"
childLayout resource identifier of a view layout that defines the views for a child (unless it is the last child within a group, in which case the lastChildLayout is used). The layout file should include at least those named views defined in "childTo"
lastChildLayout resource identifier of a view layout that defines the views for the last child within each group. The layout file should include at least those named views defined in "childTo"
childFrom A list of keys that will be fetched from the Map associated with each child.
childTo The child views that should display column in the "childFrom" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the childFrom parameter.

Public Methods

public Object getChild (int groupPosition, int childPosition)

Added in API level 1

public long getChildId (int groupPosition, int childPosition)

Added in API level 1

public View getChildView (int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)

Added in API level 1

public int getChildrenCount (int groupPosition)

Added in API level 1

public Object getGroup (int groupPosition)

Added in API level 1

public int getGroupCount ()

Added in API level 1

public long getGroupId (int groupPosition)

Added in API level 1

public View getGroupView (int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)

Added in API level 1

public boolean hasStableIds ()

Added in API level 1

public boolean isChildSelectable (int groupPosition, int childPosition)

Added in API level 1

public View newChildView (boolean isLastChild, ViewGroup parent)

Added in API level 1

Instantiates a new View for a child.

Parameters
isLastChild Whether the child is the last child within its group.
parent The eventual parent of this new View.
Returns
  • A new child View

public View newGroupView (boolean isExpanded, ViewGroup parent)

Added in API level 1

Instantiates a new View for a group.

Parameters
isExpanded Whether the group is currently expanded.
parent The eventual parent of this new View.
Returns
  • A new group View