天天看點

Android 3.0 r1 API中文文檔(108) —— ExpandableListAdapter

一、結構

public interface ExpandableListAdapter

android.widget.ExpandableListAdapter

間接子類        

      BaseExpandableListAdapter,CursorTreeAdapter,ResourceCursorTreeAdapter, SimpleCursorTreeAdapter, SimpleExpandableListAdapter

二、概述

三、公共方法

    public abstract boolean areAllItemsEnabled ()

    ExpandableListAdapter裡面的所有條目都可用嗎?如果是yes,就意味着所有條目可以選擇和點選了。

  傳回值

                   傳回True表示所有條目均可用。

      參見

  public abstract Cursor getChild (int groupPosition, int childPosition)

    擷取指定組中的指定子元素資料。

                  參數

                            groupPosition           組位置(該組内部含有子元素)

                            childPosition              子元素位置(相對于其它子元素)

                  傳回值

                            傳回指定子元素資料。

    public abstract long getChildId (int groupPosition, int childPosition)

                            groupPosition           組位置(該組内部含有子元素)

                  子元素關聯ID。

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

           擷取一個視圖對象,顯示指定組中的指定子元素資料。

                    參數

                           groupPosition  組位置(該組内部含有子元素)

                            childPosition   子元素位置(決定傳回哪個視圖)

                            isLastChild    子元素是否處于組中的最後一個

                            parent              傳回的視圖(View)對象始終依附于的視圖組。

                           指定位置上的子元素傳回的視圖對象

  public abstract int getChildrenCount (int groupPosition)

    擷取指定組中的子元素個數

                           groupPosition 組位置(決定傳回哪個組的子元素個數)

                           指定組的子元素個數

  public abstract long getCombinedChildId (long groupId, long childId)

  從清單所有項(組或子項)中獲得一個唯一的子ID号。可折疊清單要求每個元素(組或子項)在所有的子元素群組中有一個唯一的ID。本方法負責根據所給的子ID号群組ID号傳回唯一的ID。此外,若hasStableIds()是true,那麼必須要傳回穩定的ID。

                   參數

                            groupId 包含該子元素的組ID

                            childId  子元素的ID

  清單所有項(組或子項)中唯一的(和可能穩定)的子元素ID号。(譯者注:ID理論上是穩定的,不會發生沖突的情況。也就是說,這個清單會有組、子元素,它們的ID都是唯一的。) 

  public abstract Cursor getGroup (int groupPosition)

  擷取指定組中的資料

                            groupPosition 組位置

                           傳回組中的資料,也就是該組中的子元素資料。

  public abstract int getGroupCount ()

    擷取組的個數

                           組的個數

    public abstract long getGroupId (int groupPosition)

                            傳回組相關ID

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

      參數

                   groupPosition 組位置(決定傳回哪個視圖)

                   isExpanded    該組是展開狀态還是伸縮狀态

                      parent            傳回的視圖對象始終依附于的視圖組。

           傳回值

                     傳回指定組的視圖對象

           public abstract boolean hasStableIds ()

           組和子元素是否持有穩定的ID,也就是底層資料的改變不會影響到它們。

    傳回一個Boolean類型的值,如果為TRUE,意味着相同的ID永遠引用相同的對象。

           public abstract boolean isChildSelectable (int groupPosition, int childPosition)

           是否選中指定位置上的子元素。

                           groupPosition 組位置(該組内部含有這個子元素)

                           childPosition  子元素位置

                    傳回值

                    是否選中子元素

    public abstract boolean isEmpty ()

             傳回值

  如果目前擴充卡不包含任何資料則傳回True。經常用來決定一個空視圖是否應該被顯示。一個典型的實作将傳回表達式getCount() == 0的結果,但是由于getCount()包含了頭部和尾部,擴充卡可能需要不同的行為。

                 參見

    public abstract void onGroupCollapsed (int groupPosition)

    當組收縮狀态的時候此方法被調用。

                            groupPosition 收縮狀态的組索引

    public abstract void onGroupExpanded (int groupPosition)

    當組展開狀态的時候此方法被調用。

                            groupPosition 展開狀态的組位置

    public abstract void registerDataSetObserver (DataSetObserver observer)

    注冊一個觀察者(observer),當此擴充卡資料修改時即調用此觀察者。

                            observer 當資料修改時通知調用的對象。

    public abstract void unregisterDataSetObserver (DataSetObserver observer)

  取消先前通過registerDataSetObserver(DataSetObserver)方式注冊進該擴充卡中的觀         察者對象。

                              observer  取消這個觀察者的注冊

四、補充

           文章精選

ExpandableListView.OnChildClickListener

譯者署名: 情敵貝多芬

版本:Android 3.0 r1

結構

繼承關系

public static interface ExpandableListView.OnChildClickListener

java.lang.Object

android.widget.ExpandableListView.OnChildClickListener 

子類及間接子類

間接子類

類概述

這是一個定義了當可折疊清單(expandable list)裡的子元素(child)發生點選事件時調用的回調方法的接口。

公共方法

public abstract boolean onChildClick (ExpandableListView parent, View v, int groupPosition, int childPosition, long id)

  用當可折疊清單裡的子元素(child)被點選的時候被調用的回調方法。

參數

             parent                    發生點選動作的ExpandableListView

                 v                    在expandable list/ListView中被點選的視圖(View)

                 groupPosition                   包含被點選子元素的組(group)在ExpandableListView中的位置(索引)

                 childPosition                   被點選子元素(child)在組(group)中的位置

                 id                  被點選子元素(child)的行ID(索引)

    傳回值

                            當點選事件被處理時傳回true

ExpandableListView.OnGroupClickListener

public static interface ExpandableListView.OnGroupClickListener 

android.widget.ExpandableListView.OnGroupClickListener 

這是一個定義了當可折疊清單(expandable list)裡的組(group)發生點選事件時調用的回調方法的接口。

public abstract boolean onGroupClick (ExpandableListView parent, View v, int groupPosition, long id)

  用當可折疊清單裡的組(group)被點選的時候被調用的回調方法。

      parent            發生點選事件的ExpandableListConnector

      v                    在expandable list/ListView中被點選的視圖(View)

      groupPosition  被點選的組(group)在ExpandableListConnector中的位置(索引)

      id                   被點選的組(group)的行ID(索引)

      當點選事件被處理的時候傳回true

ExpandableListView.OnGroupCollapseListener

譯者署名: 深夜未眠

public interface ExpandableListView.OnGroupCollapseListener

         java.lang.Object

         android.widget.ExpandableListView.OnGroupCollapseListener 

  ExpandableListActivity 

         當收縮某個組時,就會發出通知。

       public abstract void onGroupCollapse (int groupPosition)

         每當收縮目前可伸縮清單中的某個組時,就調用該方法。

                            groupPosition 組位置,也就是收縮的那個組的位置。

ExpandableListView.OnGroupExpandListener

public interface ExpandableListView.OnGroupExpandListener

         android.widget.ExpandableListView.OnGroupExpandListener 

         當展開某個組時,就會發出通知。

  public abstract void onGroupExpand (int groupPosition)

  每當展開目前可伸縮清單中的某個組時,就調用該方法。

    參數

                            groupPosition 組位置,也就是展開的那個組的位置。

繼續閱讀