数据适配器简介(ExpandableListAdapter)

Android 为我们提供了 android.widget.Adapter android.widget.ExpandableListAdapter 两大类数据适配器接口。
android.widget.ExpandableListAdapter接口 主要和 android.widget.ExpandableListView 配合使用
android.widget.Adapter接口 主要和 android.widget.AdapterView android.widget.ExpandableListView 之除外的其他类配合使用。
<wbr style="line-height:22px"><div style="line-height:22px">以下是<span style="line-height:22px"><strong>ExpandableListAdapter</strong><span style="line-height:22px">接口及子接口和实现类</span></span>的关系图</div> </wbr>
<wbr style="line-height:25px"><span style="line-height:25px">图1</span> <div style="line-height:25px"> <span style="line-height:25px"></span> <div style="line-height:25px"><img alt="数据适配器简介(ExpandableListAdapter) - hubingforever - 民主与科学" src="http://img6.ph.126.net/ItRICD98CJRKu2QtU4PTPQ==/1570348895085770036.png" style="line-height:25px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; max-width:100%; margin-top:0px; margin-right:10px; margin-bottom:0px; margin-left:0px"></div> <span style="color:#003366; line-height:25px"><br style="line-height:25px"></span><span style="color:#ff00ff; line-height:25px">ExpandableListAdapter</span><span style="color:#003366; line-height:25px">申明的主要接口有:</span><span style="color:#0000ff; line-height:25px">getChild</span><span style="color:#003366; line-height:25px">系列和</span><span style="color:#0000ff; line-height:25px">getGroup</span><span style="color:#003366; line-height:25px">系列及</span><span style="color:#0000ff; line-height:25px">getCombined</span><span style="color:#003366; line-height:25px">系列<br style="line-height:25px"> 实现</span><span style="color:#ff6600; line-height:25px">ExpandableListAdapter</span><span style="color:#003366; line-height:25px">的接口:<br style="line-height:25px"></span><span style="color:#0000ff; line-height:25px">无</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">实现</span><span style="color:#ff6600; line-height:25px">ExpandableListAdapter</span><span style="color:#003366; line-height:25px">的类有</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#993300; line-height:25px">BaseExpandableListAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#0000ff; line-height:25px">CursorTreeAdapter</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">ResourceCursorTreeAdapter<br style="line-height:25px"> SimpleCursorTreeAdapter</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#993300; line-height:25px">SimpleExpandableListAdapter</span><br style="line-height:25px"> 更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920105310379567/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">ExpandableListAdapter</a></strong>》</div> <div style="line-height:25px"> <span style="line-height:25px"><wbr style="line-height:25px">一、BaseExpandableListAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">BaseExpandableListAdapter</span>实现了接口<span style="color:#ff6600; line-height:25px">ExpandableListAdapter</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">BaseExpandableListAdapter</span>的子类<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">CursorTreeAdapter</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">ResourceCursorTreeAdapter</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">BaseExpandableListAdapter</span>主要实现了<span style="color:#ff6600; line-height:25px">ExpandableListAdapter</span>接口的四个方法<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">getCombinedChildId(long,long)<br style="line-height:25px"> getCombinedGroupId(long)<br style="line-height:25px"> onGroupCollapsed(intgroupPosition)[空实现]<br style="line-height:25px"> onGroupExpanded(intgroupPosition)[空实现]</span><br style="line-height:25px"> 更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/1710405792010533319399/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">BaseExpandableListAdapter</a></strong>》</wbr> </div> <div style="line-height:25px"> <span style="line-height:25px"><wbr style="line-height:25px">二、CursorTreeAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">CursorTreeAdapter</span>继承于<span style="color:#ff6600; line-height:25px">BaseExpandableListAdapter</span>是个虚类。<br style="line-height:25px"> 它为<span style="color:#ff9900; line-height:25px">cursor</span>和<span style="color:#ff6600; line-height:25px">ExpandableListView</span>提供了连接的桥梁。<br style="line-height:25px"><span style="color:#99cc00; line-height:25px">CursorTreeAdapter</span>的子类有<br style="line-height:25px"><span style="color:#993300; line-height:25px">CursorTreeAdapte</span>r<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">ResourceCursorTreeAdapter</span><br style="line-height:25px"><span style="color:#3366ff; line-height:25px">SimpleCursorTreeAdapter</span><br style="line-height:25px"> 使用<span style="color:#993300; line-height:25px">CursorTreeAdapter</span>需要实现五个方法:<span style="color:#0000ff; line-height:25px">bindChildView,bindGroupView,getChildrenCursor,newChildView,newGroupView</span></wbr> </div> <div style="line-height:25px">更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/171040579201041582131670/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">CursorTreeAdapter</a></strong>》</div> <div style="line-height:25px"> <span style="line-height:25px"><wbr style="line-height:25px">三、ResourceCursorTreeAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">ResourceCursorTreeAdapter</span>继承<span style="color:#ff6600; line-height:25px">CursorTreeAdapter</span>。<br style="line-height:25px"><span style="color:#003366; line-height:25px">它让用户提供</span><span style="color:#0000ff; line-height:25px">Group</span><span style="color:#003366; line-height:25px">和</span><span style="color:#0000ff; line-height:25px">child</span><span style="color:#003366; line-height:25px">的布局文件id,<br style="line-height:25px"> 然后实现来自于</span><span style="color:#800000; line-height:25px">CursorTreeAdapter</span><span style="color:#003366; line-height:25px">的两个方法(</span><span style="color:#0000ff; line-height:25px">newChildView,newGroupView</span><span style="color:#003366; line-height:25px">)来为用户创建Group和child的View</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">ResourceCursorTreeAdapter</span>的子类有<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">SimpleCursorTreeAdapter</span><br style="line-height:25px"><span style="color:#993300; line-height:25px">ResourceCursorTreeAdapter</span>实现了来自于CursorTreeAdapter的两个方法:<br style="line-height:25px"><span style="color:#0000ff; line-height:25px">newChildView,newGroupView</span><br style="line-height:25px"> 但使用<span style="color:#993300; line-height:25px">CursorTreeAdapter</span>还需要实现下面三个方法:bindChildView,bindGroupView,getChildrenCursor。<br style="line-height:25px"> 更多可参考《ResourceCursorTreeAdapter》<br style="line-height:25px"><span style="line-height:25px"><wbr style="line-height:25px">四、SimpleCursorTreeAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">SimpleCursorTreeAdapter</span>继承于<span style="color:#ff6600; line-height:25px">ResourceCursorTreeAdapter</span>。<br style="line-height:25px"><span style="color:#003366; line-height:25px">它为cursor和ExpandableListView提供了连接的桥梁。<br style="line-height:25px"> 它提供把cursor的数据绑定到Group和child的布局文件中的控件的功能。绑定的控件只能是</span><span style="color:#0000ff; line-height:25px">TextView</span><span style="color:#003366; line-height:25px">和</span><span style="color:#0000ff; line-height:25px">ImageView</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">SimpleCursorTreeAdapter没有子类。</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">他实现了来自于ResourceCursorTreeAdapter的两个方法:</span><br style="line-height:25px"><span style="color:#003366; line-height:25px"></span><span style="color:#0000ff; line-height:25px">bindChildView,bindGroupView</span><br style="line-height:25px"><span style="color:#003366; line-height:25px">但使用CursorTreeAdapter还需要实现一个方法:getChildrenCursor</span></wbr></wbr> </div> <div style="line-height:25px">更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/17104057920104158492742/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">SimpleCursorTreeAdapter</a></strong>》</div> <div style="line-height:25px"> <span style="line-height:25px"><wbr style="line-height:25px">五、SimpleExpandableListAdapter</wbr></span><wbr style="line-height:25px"><br style="line-height:25px"><span style="color:#ff00ff; line-height:25px">SimpleExpandableListAdapter</span>继承于BaseExpandableListAdapter。<br style="line-height:25px"> 他负责把静态的group数据和child数据映射到XML文件中定的group和child视图上。<br style="line-height:25px"><span style="color:#993300; line-height:25px">SimpleExpandableListAdapter</span>无子类。<br style="line-height:25px"> 更多请参考《<strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/171040579201041705736803/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">SimpleExpandableListAdapter</a></strong>》</wbr> </div> </wbr>
评论这张
转发至微博
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值