Most visited

Recently visited

Added in API level 1

BaseExpandableListAdapter

public abstract class BaseExpandableListAdapter
extends Object implements ExpandableListAdapter, HeterogeneousExpandableList

java.lang.Object
   ↳ android.widget.BaseExpandableListAdapter
Known Direct Subclasses
Known Indirect Subclasses


ExpandableListAdapter基类,用于将数据和视图从某些数据提供到可扩展列表视图。

继承此类的适配器应验证 getCombinedChildId(long, long)getCombinedGroupId(long)的基本实现在从组/子ID中生成唯一ID时是正确的。

也可以看看:

Summary

Public constructors

BaseExpandableListAdapter()

Public methods

boolean areAllItemsEnabled()
int getChildType(int groupPosition, int childPosition)

获取将由 getChildView(int, int, boolean, View, ViewGroup)创建的指定子项目的子视图类型。

int getChildTypeCount()

返回将由 getChildView(int, int, boolean, View, ViewGroup)创建的子视图类型的数量。

long getCombinedChildId(long groupId, long childId)

如果您预计基于此方案的ID发生冲突,请覆盖此方法:

基础实现返回一个长:

  • 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)

    如果您预计基于此方案的ID发生冲突,请覆盖此方法:

    基础实现返回一个长:

  • 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)

    获取将由 getGroupView(int, boolean, View, ViewGroup)创建的组视图类型。

    int getGroupTypeCount()

    返回将由 getGroupView(int, boolean, View, ViewGroup)创建的组视图类型的数量。

    boolean isEmpty()

    void notifyDataSetChanged()
    void notifyDataSetInvalidated()
    void onGroupCollapsed(int groupPosition)

    当一个组被折叠时调用。

    void onGroupExpanded(int groupPosition)

    当一个组被扩展时调用。

    void registerDataSetObserver(DataSetObserver observer)
    void unregisterDataSetObserver(DataSetObserver observer)

    Inherited methods

    From class java.lang.Object
    From interface android.widget.ExpandableListAdapter
    From interface android.widget.HeterogeneousExpandableList

    Public constructors

    BaseExpandableListAdapter

    Added in API level 1
    BaseExpandableListAdapter ()

    Public methods

    areAllItemsEnabled

    Added in API level 1
    boolean areAllItemsEnabled ()

    Returns
    boolean

    getChildType

    Added in API level 8
    int getChildType (int groupPosition, 
                    int childPosition)

    获取指定子项目将由 getChildView(int, int, boolean, View, ViewGroup)创建的子视图类型。

    Parameters
    groupPosition int: the position of the group that the child resides in
    childPosition int: the position of the child with respect to other children in the group
    Returns
    int 0 for any group or child position, since only one child type count is declared.

    getChildTypeCount

    Added in API level 8
    int getChildTypeCount ()

    返回将由getChildView(int, int, boolean, View, ViewGroup)创建的子视图类型的数量。 每种类型代表一组视图,可以在getChildView(int, int, boolean, View, ViewGroup)中对任何组进行转换。 如果适配器始终为所有子项返回相同类型的视图,则此方法应返回1。

    This method will only be called when the adapter is set on the AdapterView.

    Returns
    int 1 as a default value in BaseExpandableListAdapter.

    getCombinedChildId

    Added in API level 1
    long getCombinedChildId (long groupId, 
                    long childId)

    如果您预计基于此方案的ID发生冲突,请覆盖此方法:

    基础实现返回一个长:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 1.
  • bit 1-31: Lower 31 bits of the groupId
  • bit 32-63: Lower 32 bits of the childId.

    获取此列表中任何项目(组或子项)上唯一的子项的ID。 展开式列表要求每个项目(组或小孩)在列表中的所有子项和组中都有唯一的ID。 此方法负责返回给定孩子ID和组ID的唯一ID。 此外,如果hasStableIds()为真,则返回的ID也必须稳定。

    Parameters
    groupId long: The ID of the group that contains this child.
    childId long: The ID of the child.
    Returns
    long The unique (and possibly stable) ID of the child across all groups and children in this list.
  • getCombinedGroupId

    Added in API level 1
    long getCombinedGroupId (long groupId)

    如果您预计基于此方案的ID发生冲突,请覆盖此方法:

    基础实现返回一个长:

  • bit 0: Whether this ID points to a child (unset) or group (set), so for this method this bit will be 0.
  • bit 1-31: Lower 31 bits of the groupId
  • bit 32-63: Lower 32 bits of the childId.

    获取此列表中任何项目(组或子项)上唯一的组的ID。 展开式列表要求每个项目(组或小孩)在列表中的所有子项和组中都有唯一的ID。 该方法负责返回给定组ID的唯一ID。 此外,如果hasStableIds()为真,则返回的ID也必须稳定。

    Parameters
    groupId long: The ID of the group
    Returns
    long The unique (and possibly stable) ID of the group across all groups and children in this list.
  • getGroupType

    Added in API level 8
    int getGroupType (int groupPosition)

    获取将由getGroupView(int, boolean, View, ViewGroup)创建的组视图类型。 为指定的组项目。

    Parameters
    groupPosition int: the position of the group for which the type should be returned.
    Returns
    int 0 for any groupPosition, since only one group type count is declared.

    getGroupTypeCount

    Added in API level 8
    int getGroupTypeCount ()

    Returns the number of types of group Views that will be created by getGroupView(int, boolean, View, ViewGroup) . Each type represents a set of views that can be converted in getGroupView(int, boolean, View, ViewGroup) . If the adapter always returns the same type of View for all group items, this method should return 1.

    This method will only be called when the adapter is set on the AdapterView.

    Returns
    int 1 as a default value in BaseExpandableListAdapter.

    isEmpty

    Added in API level 1
    boolean isEmpty ()

    Returns
    boolean

    notifyDataSetChanged

    Added in API level 1
    void notifyDataSetChanged ()

    也可以看看:

    notifyDataSetInvalidated

    Added in API level 1
    void notifyDataSetInvalidated ()

    也可以看看:

    onGroupCollapsed

    Added in API level 1
    void onGroupCollapsed (int groupPosition)

    当一个组被折叠时调用。

    Parameters
    groupPosition int: The group being collapsed.

    onGroupExpanded

    Added in API level 1
    void onGroupExpanded (int groupPosition)

    当一个组被扩展时调用。

    Parameters
    groupPosition int: The group being expanded.

    registerDataSetObserver

    Added in API level 1
    void registerDataSetObserver (DataSetObserver observer)

    Parameters
    observer DataSetObserver

    unregisterDataSetObserver

    Added in API level 1
    void unregisterDataSetObserver (DataSetObserver observer)

    Parameters
    observer DataSetObserver

    Hooray!