天天看點

Android 中文 API (93) —— BaseExpandableListAdapter

前言

聲明

  歡迎轉載,但請保留文章原始出處:) 

正文

  一、結構

public abstract class baseexpandablelistadapter extends object

java.lang.object

android.widget.baseexpandablelistadapter

直接子類

                cursortreeadapter,simpleexpandablelistadapter

間接子類

  二、概述

  (譯者注:組元素表示可折疊的清單項,子元素表示清單項展開後看到的多個子元素項。由于可折疊清單單純尋找組元素和子元素的id不是很友善,是以使用聯合id的方式來解決。于是有了getcombinedchildid()和getcombinedgroupid()方法。在andorid自帶的apidomos的例子中有這個的代碼:app/view/expandablelist1)。

  三、公共方法 

  public boolean areallitemsenabled ()

  是否啟用所有元素。

  public int getchildtype (int groupposition, int childposition)

  參數

                   groupposition 子元素所在的組位置

                       childposition 子元素所在的位置

                 傳回值

                       0表示任意一個子元素類型,是以此時應當隻聲明一種子元素類型。

  public int getchildtypecount()

             傳回值

                   baseexpandablelistadapter預設傳回1。

  public long getcombinedchildid (long groupid, long childid)

  若你預見以下預設實作的ids可能出現沖突,請重寫本方法。

  實作傳回一個long型:

  * 第0位:不管id指向的是一個子元素(未設定)還是一個組(已設定),對于本方法bit值為1.

  * 第1-31位:小于31位的組id。

  * 第32-63位:小于32位的子元素id。

               參數

                   groupid   包含該子元素的組id

                   childid      子元素的id号

                 傳回

                   清單所有項(組或子項)中唯一的(和可能穩定)的子元素id号。

  public long getcombinedgroupid (long groupid)

  若你預見以下預設實作産生ids沖突的話,請重寫本方法。

   * 第0位:不管id指向的是一個子元素(未設定)還是一個組(已設定),對于本方法bit值為1.

   * 第1-31位:小于31位的組id。

   * 第32-63位:小于32位的子元素id。

  public int getgrouptype (int groupposition)

<code>    </code>  <code>參數</code>

<code>        </code>  <code>groupposition </code><code>應傳回類型所在組的位置</code>

<code>    </code>  <code>傳回</code>

<code>        </code>  <code>0</code><code>表示任意組位置,是以此時應當隻申明了一種組類型。</code>

<code> </code>

  public int getgrouptypecount ()

  本方法将僅當擴充卡被adapterview設定時調用。

            傳回

              baseexpandablelistadapter預設傳回1.

  public boolean isempty ()

          (譯者注:如果擴充卡沒有任何資料,傳回真。參見adapter)

  public void notifydatasetchanged ()

  <code>(譯者注:當背景資料集發生改變時,調用此方法響應資料集的更改。)</code><code></code>

  <code>參見</code><code></code>

  public void notifydatasetinvalidated ()

              <code>(譯者注:當背景資料集不被驗證的時候,調用此方法。)</code><code></code>

<code>      </code>   <code>參見</code><code></code>

  public void ongroupcollapsed (int groupposition)

  <code>當組折疊的時候被調用。</code><code></code>

                   參數

                            groupposition 要折疊的組所在位置

  public void ongroupexpanded (int groupposition)

  當組展開的時候被調用。

  public void registerdatasetobserver (datasetobserver observer)

  (譯者注:注冊當用該擴充卡修改資料時調用的觀察器。)

  public void unregisterdatasetobserver (datasetobserver observer)

  (譯者注:登出之前通過 <code>registerdatasetobserver(datasetobserver)</code> 方法注冊到該擴充卡的觀察器。)

轉載:http://www.cnblogs.com/over140/archive/2011/01/18/1937921.html

繼續閱讀