資料配接器簡介(ExpandableListAdapter)

來源:互聯網
上載者:User

Android為我們提供了android.widget.Adapter和android.widget.ExpandableListAdapter兩大類資料配接器介面。android.widget.ExpandableListAdapter介面主要和android.widget.ExpandableListView配合使用而android.widget.Adapter介面主要和android.widget.AdapterView中android.widget.ExpandableListView之除外的其他類配合使用。 

以下是ExpandableListAdapter介面及子介面和實作類別的關係圖

圖1

 
ExpandableListAdapter申明的主要介面有:getChild系列和getGroup系列及getCombined系列

實現ExpandableListAdapter的介面:

    無
實現ExpandableListAdapter的類有
    BaseExpandableListAdapter
        CursorTreeAdapter
            ResourceCursorTreeAdapter

                SimpleCursorTreeAdapter
    SimpleExpandableListAdapter

更多請參考《ExpandableListAdapter》一、BaseExpandableListAdapter

    BaseExpandableListAdapter實現了介面ExpandableListAdapter

    BaseExpandableListAdapter的子類

        CursorTreeAdapter

            ResourceCursorTreeAdapter

    BaseExpandableListAdapter主要實現了ExpandableListAdapter介面的四個方法
    getCombinedChildId(long, long)

    getCombinedGroupId(long)

    onGroupCollapsed(int groupPosition)[空實現]

    onGroupExpanded(int groupPosition)[空實現]

更多請參考《BaseExpandableListAdapter》二、CursorTreeAdapter

    CursorTreeAdapter繼承於BaseExpandableListAdapter是個虛類。

    它為cursor和ExpandableListView提供了串連的橋樑。

    CursorTreeAdapter的子類有

            CursorTreeAdapter

                ResourceCursorTreeAdapter

                    SimpleCursorTreeAdapter

    使用CursorTreeAdapter需要實現五個方法:bindChildView,bindGroupView,getChildrenCursor,newChildView,newGroupView更多請參考《CursorTreeAdapter》三、ResourceCursorTreeAdapter

    ResourceCursorTreeAdapter繼承CursorTreeAdapter。
    它讓使用者提供Group和child的布局檔案id,

    然後實現來自於CursorTreeAdapter的兩個方法(newChildView,newGroupView)來為使用者建立Group和child的View

    ResourceCursorTreeAdapter的子類有

                    SimpleCursorTreeAdapter

    ResourceCursorTreeAdapter實現了來自於CursorTreeAdapter的兩個方法:

    newChildView,newGroupView

    但使用CursorTreeAdapter還需要實現下面三個方法:bindChildView,bindGroupView,getChildrenCursor。

    更多可參考《ResourceCursorTreeAdapter》
四、SimpleCursorTreeAdapter

    SimpleCursorTreeAdapter繼承於ResourceCursorTreeAdapter。
    它為cursor和ExpandableListView提供了串連的橋樑。

    它提供把cursor的資料繫結到Group和child的布局檔案中的控制項的功能。綁定的控制項只能是TextView和ImageView
    SimpleCursorTreeAdapter沒有子類。
    他實現了來自於ResourceCursorTreeAdapter的兩個方法:
    bindChildView,bindGroupView
    但使用CursorTreeAdapter還需要實現一個方法:getChildrenCursor更多請參考《SimpleCursorTreeAdapter》五、SimpleExpandableListAdapter

    SimpleExpandableListAdapter繼承於BaseExpandableListAdapter。

    他負責把靜態group資料和child資料對應到XML檔案中定的group和child視圖上。

    SimpleExpandableListAdapter無子類。

    更多請參考《SimpleExpandableListAdapter

 評論這張轉寄至微博

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.