English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.ExpandableListView

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.AdapterView
android.widget.AbsListView
android.widget.ListView
android.widget.ExpandableListView

A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view.

Expandable lists are able to show an indicator beside each item to display the item's current state (usually one of expanded group, collapsed group, child, or last child). The default style for an ExpandableListView provides indicators which will be shown next to Views given to the ExpandableListView. The layouts android.R.layout.simple_expandable_list_item_1 and android.R.layout.simple_expandable_list_item_2 (which should be used with SimpleCursorTreeAdapter) contain the preferred position information for indicators.

The context menu information set by an ExpandableListView will be a ExpandableListView.ExpandableListContextMenuInfo object with packedPosition being a packed position that can be used with getPackedPositionType(long) and the other similar methods.

Also see ViewGroup.LayoutParams for layout attributes.

Note: You cannot use the value wrap_content for the android:layout_height attribute of a ExpandableListView in XML if the parent's size is also not strictly specified (for example, if the parent were ScrollView you could not specify wrap_content since it also can be any length. However, you can use wrap_content if the ExpandableListView parent has a specific size, such as 100 pixels.

Nested Classes
ExpandableListView.ExpandableListContextMenuInfo Extra menu information specific to an ExpandableListView provided to the onPopulateContextMenu(ContextMenu, View, Object) callback when a context menu is brought up for this AdapterView. 
ExpandableListView.OnChildClickListener Interface definition for a callback to be invoked when a child in this expandable list has been clicked. 
ExpandableListView.OnGroupClickListener Interface definition for a callback to be invoked when a group in this expandable list has been clicked. 
ExpandableListView.OnGroupCollapseListener Used for being notified when a group is collapsed  
ExpandableListView.OnGroupExpandListener Used for being notified when a group is expanded  

Summary

XML Attributes inherited from class android.widget.ListView
XML Attributes inherited from class android.widget.AbsListView
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View

Constants

      Value  
int  PACKED_POSITION_TYPE_CHILD  The packed position represents a child.  0x00000001 
int  PACKED_POSITION_TYPE_GROUP  The packed position represents a group.  0x00000000 
int  PACKED_POSITION_TYPE_NULL  The packed position represents a neither/null/no preference.  0x00000002 
long  PACKED_POSITION_VALUE_NULL  The value for a packed position that represents neither/null/no preference.  4294967295  0x00000000ffffffff 
Constants inherited from class android.widget.AbsListView
Constants inherited from class android.widget.AdapterView
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View
Fields inherited from class android.widget.ListView
Fields inherited from class android.widget.AbsListView
Fields inherited from class android.widget.AdapterView
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

          ExpandableListView(Context context)
          ExpandableListView(Context context, AttributeSet attrs, Map inflateParams)
          ExpandableListView(Context context, AttributeSet attrs, Map inflateParams, int defStyle)

Public Methods

        boolean  collapseGroup(int groupPos)
Collapse a group in the grouped list view
        void  expandGroup(int groupPos)
Expand a group in the grouped list view
        ListAdapter  getAdapter()
This method should not be used, use getExpandableListAdapter().
        ExpandableListAdapter  getExpandableListAdapter()
Gets the adapter that provides data to this view.
        long  getExpandableListPosition(int flatListPosition)
Converts a flat list position (the raw position of an item (child or group) in the list) to an group and/or child position (represented in a packed position).
        int  getFlatListPosition(long packedPosition)
Converts a group and/or child position to a flat list position.
      static  int  getPackedPositionChild(long packedPosition)
Gets the child position from a packed position that is of PACKED_POSITION_TYPE_CHILD type (use getPackedPositionType(long)).
      static  long  getPackedPositionForChild(int groupPosition, int childPosition)
Returns the packed position representation of a child's position.
      static  long  getPackedPositionForGroup(int groupPosition)
Returns the packed position representation of a group's position.
      static  int  getPackedPositionGroup(long packedPosition)
Gets the group position from a packed position.
      static  int  getPackedPositionType(long packedPosition)
Gets the type of a packed position.
        long  getSelectedId()
Gets the ID of the currently selected group or child.
        long  getSelectedPosition()
Gets the position of the currently selected group or child (along with its type).
        boolean  performItemClick(View v, int position, long id)
Call the OnItemClickListener, if it is defined.
        void  setAdapter(ExpandableListAdapter adapter)
Sets the adapter that provides data to this view.
        void  setAdapter(ListAdapter adapter)
This overloaded method should not be used, instead use setAdapter(ExpandableListAdapter).
        void  setChildDivider(Drawable childDivider)
Sets the drawable that will be drawn adjacent to every child in the list.
        void  setOnChildClickListener(OnChildClickListener onChildClickListener)
        void  setOnGroupClickListener(OnGroupClickListener onGroupClickListener)
        void  setOnGroupCollapseListener(OnGroupCollapseListener onGroupCollapseListener)
        void  setOnGroupExpandListener(OnGroupExpandListener onGroupExpandListener)
        void  setOnItemClickListener(OnItemClickListener l)
Register a callback to be invoked when an item has been clicked and the caller prefers to receive a ListView-style position instead of a group and/or child position.
        boolean  setSelectedChild(int groupPosition, int childPosition, boolean shouldExpandGroup)
Sets the selection to the specified child.
        void  setSelectedGroup(int groupPosition)