SimpleExpandableListAdapter
public
class
SimpleExpandableListAdapter
extends BaseExpandableListAdapter
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 expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, int lastChildLayout, 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 groupLayout, String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, int childLayout, 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.
|
Inherited methods |
From class
android.widget.BaseExpandableListAdapter
boolean
|
areAllItemsEnabled()
|
int
|
getChildType(int groupPosition, int childPosition)
Get the type of child View that will be created by
ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup)
for the specified child item.
|
int
|
getChildTypeCount()
Returns the number of types of child Views that will be created by
ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup)
.
|
long
|
getCombinedChildId(long groupId, long childId)
Override this method if you foresee a clash in IDs based on this scheme:
Base implementation returns a long:
bit 0: Whether this ID points to a child (unset) or group (set), so for this method
this bit will be 1.
|
long
|
getCombinedGroupId(long groupId)
Override this method if you foresee a clash in IDs based on this scheme:
Base implementation returns a long:
bit 0: Whether this ID points to a child (unset) or group (set), so for this method
this bit will be 0.
|
int
|
getGroupType(int groupPosition)
Get the type of group View that will be created by
ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup)
.
|
int
|
getGroupTypeCount()
Returns the number of types of group Views that will be created by
ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup)
.
|
boolean
|
isEmpty()
|
void
|
notifyDataSetChanged()
|
void
|
notifyDataSetInvalidated()
|
void
|
onGroupCollapsed(int groupPosition)
Called when a group is collapsed.
|
void
|
onGroupExpanded(int groupPosition)
Called when a group is expanded.
|
void
|
registerDataSetObserver(DataSetObserver observer)
|
void
|
unregisterDataSetObserver(DataSetObserver observer)
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
From interface
android.widget.ExpandableListAdapter
abstract
boolean
|
areAllItemsEnabled()
|
abstract
Object
|
getChild(int groupPosition, int childPosition)
Gets the data associated with the given child within the given group.
|
abstract
long
|
getChildId(int groupPosition, int childPosition)
Gets the ID for the given child within the given group.
|
abstract
View
|
getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
Gets a View that displays the data for the given child within the given
group.
|
abstract
int
|
getChildrenCount(int groupPosition)
Gets the number of children in a specified group.
|
abstract
long
|
getCombinedChildId(long groupId, long childId)
Gets an ID for a child that is unique across any item (either group or
child) that is in this list.
|
abstract
long
|
getCombinedGroupId(long groupId)
Gets an ID for a group that is unique across any item (either group or
child) that is in this list.
|
abstract
Object
|
getGroup(int groupPosition)
Gets the data associated with the given group.
|
abstract
int
|
getGroupCount()
Gets the number of groups.
|
abstract
long
|
getGroupId(int groupPosition)
Gets the ID for the group at the given position.
|
abstract
View
|
getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
Gets a View that displays the given group.
|
abstract
boolean
|
hasStableIds()
Indicates whether the child and group IDs are stable across changes to the
underlying data.
|
abstract
boolean
|
isChildSelectable(int groupPosition, int childPosition)
Whether the child at the specified position is selectable.
|
abstract
boolean
|
isEmpty()
|
abstract
void
|
onGroupCollapsed(int groupPosition)
Called when a group is collapsed.
|
abstract
void
|
onGroupExpanded(int groupPosition)
Called when a group is expanded.
|
abstract
void
|
registerDataSetObserver(DataSetObserver observer)
|
abstract
void
|
unregisterDataSetObserver(DataSetObserver observer)
|
|
From interface
android.widget.HeterogeneousExpandableList
abstract
int
|
getChildType(int groupPosition, int childPosition)
Get the type of child View that will be created by
ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup)
for the specified child item.
|
abstract
int
|
getChildTypeCount()
Returns the number of types of child Views that will be created by
ExpandableListAdapter.getChildView(int, int, boolean, View, ViewGroup)
.
|
abstract
int
|
getGroupType(int groupPosition)
Get the type of group View that will be created by
ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup)
.
|
abstract
int
|
getGroupTypeCount()
Returns the number of types of group Views that will be created by
ExpandableListAdapter.getGroupView(int, boolean, View, ViewGroup)
.
|
|
Public constructors
SimpleExpandableListAdapter
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)
Constructor
Parameters |
context |
Context : The context where the ExpandableListView
associated with this SimpleExpandableListAdapter is
running |
groupData |
List : 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 |
int : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each group. |
groupTo |
int : 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 |
List : 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 |
int : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each child. |
childTo |
int : 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. |
SimpleExpandableListAdapter
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)
Constructor
Parameters |
context |
Context : The context where the ExpandableListView
associated with this SimpleExpandableListAdapter is
running |
groupData |
List : 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 |
int : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each group. |
groupTo |
int : 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 |
List : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each child. |
childTo |
int : 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. |
SimpleExpandableListAdapter
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)
Constructor
Parameters |
context |
Context : The context where the ExpandableListView
associated with this SimpleExpandableListAdapter is
running |
groupData |
List : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each group. |
groupTo |
int : 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 |
List : 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 |
int : 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 |
String : A list of keys that will be fetched from the Map
associated with each child. |
childTo |
int : 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
getChild
public Object getChild (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int |
childPosition |
int |
getChildId
public long getChildId (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int |
childPosition |
int |
getChildView
public View getChildView (int groupPosition,
int childPosition,
boolean isLastChild,
View convertView,
ViewGroup parent)
Parameters |
groupPosition |
int |
childPosition |
int |
isLastChild |
boolean |
convertView |
View |
parent |
ViewGroup |
getChildrenCount
public int getChildrenCount (int groupPosition)
Parameters |
groupPosition |
int |
getGroup
public Object getGroup (int groupPosition)
Parameters |
groupPosition |
int |
getGroupCount
public int getGroupCount ()
getGroupId
public long getGroupId (int groupPosition)
Parameters |
groupPosition |
int |
getGroupView
public View getGroupView (int groupPosition,
boolean isExpanded,
View convertView,
ViewGroup parent)
Parameters |
groupPosition |
int |
isExpanded |
boolean |
convertView |
View |
parent |
ViewGroup |
hasStableIds
public boolean hasStableIds ()
isChildSelectable
public boolean isChildSelectable (int groupPosition,
int childPosition)
Parameters |
groupPosition |
int |
childPosition |
int |
newChildView
public View newChildView (boolean isLastChild,
ViewGroup parent)
Instantiates a new View for a child.
Parameters |
isLastChild |
boolean : Whether the child is the last child within its group. |
parent |
ViewGroup : The eventual parent of this new View. |
Returns |
View |
A new child View |
newGroupView
public View newGroupView (boolean isExpanded,
ViewGroup parent)
Instantiates a new View for a group.
Parameters |
isExpanded |
boolean : Whether the group is currently expanded. |
parent |
ViewGroup : The eventual parent of this new View. |
Returns |
View |
A new group View |