1) SimpleExpandableListAdapter 和 BaseExpandableListAdapter
其构造函数接受八个参数
- this(context,groupData,expandedGroupLayout,collapsedGroupLayout,groupFrom,groupTo,childData,childLayout,lastChildLayout,childFrom,childTo);
this(context, groupData, expandedGroupLayout, collapsedGroupLayout, groupFrom, groupTo, childData, childLayout, lastChildLayout, childFrom, childTo);
一般在使用中 expandedGroupLayout, collapsedGroupLayout 是一个参数生成的, childLayout, lastChildLayout 也是一个参数生成的。之所以区别它们是由于存在这样的需求:展示不同动作下不同的 view (展开和合起)、展示不同组之间最后一个孩子节点的现实布局。
这里需要注意一点在 BaseExpandableListAdapter 中,如果使用以下类似 newGroupView 方法
- publicViewnewGroupView(booleanisExpanded,ViewGroupparent){
-
returnmInflater.inflate((isExpanded)?mExpandedGroupLayout:mCollapsedGroupLayout,
-
parent,false);
public View newGroupView(boolean isExpanded, ViewGroup parent) {
return mInflater.inflate((isExpanded) ? mExpandedGroupLayout : mCollapsedGroupLayout,
parent, false);
在绑定其内容时要注意以下几点:
-
其绑定的内容一定要和 groupPosition 相对应,其内容最好不要动态生成否则会导致不稳定的绑定。类似如果是要绑定孩子节点的内容,则要和 groupPosition 、 childPosition 一一对应。并且每次调用都需要重写绑定一次,不能根据 convertView 进行判定。( convertView 是 getChildView 等方法里面的参数)
-
重写 getChild 方法时需要返回自己所需的数据结构,视情况定义自己的数据结构。
-
mInflater.inflate 方法在实例化一个 layout 时,可能会创建了别的 group 的 layout ,(这个暂时没有弄清楚为什么会有这样的原因,帮忙补充一下)。可是当使用 TextView textView = new TextView(Class.this) 时,不会产生这样的问题,每次绑定内容时 convertView 一定是空的。
2 ) SimpleCursorTreeAdapter 和 ResourceCursorTreeAdapter
该类接受一个 cursor 作为参数,而 musicplayer 中则接受一个 null 值。这里使用 AsyncQueryHandler 生成内部的 cursor 。
其流程如下:
-
首先创建在适配其中创建 AsyncQueryHandler ,此时 cursor 为空
-
在主程序中调用适配器的 AsyncQueryHandler 开始一个 sql 语句,此时在重载的 completeXX 方法中将生成的 cursor 赋给适配器
- @Override
-
protectedvoidonQueryComplete(inttoken,Objectcookie,Cursorcursor){
-
-
if(cursor!=null){
- cursor=mActivity.mergedCursor(cursor);
- }
- mActivity.init(cursor);
- }
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
//Log.i("@@@", "query complete: " + cursor.getCount() + " " + mActivity);
if (cursor != null) {
cursor = mActivity.mergedCursor(cursor);
}
mActivity.init(cursor);
}
3.适配器自动调用 get 和 bind 方法生成布局。在绑定其内容时要注意使用了 cursor 不能够自定义 group 和 child 的大小,其大小由 cursor 指定
相关推荐
Android BaseExpandableListAdapter 教程
NULL 博文链接:https://xieruilin.iteye.com/blog/726494
http://blog.csdn.net/richiezhu/article/details/50906152 BaseExpandableListAdapter
收集的一些关于Android的学习...Android之Adapter用法总结,Android中图片的处理,BaseExpandableListAdapter的使用,反编译android app,详解 Android 的 Activity 组件,需要的朋友可以下载查看(直接双击html文件查看即可)
在某些android开发群里,看到有些新手问怎么实现QQ好友列表,其实网上一搜挺多的。接触Android,也才一年的时间,大部分时间花在工作上(解bug。。。),界面上开发很少参与。自己维护的系统应用里,有个...
android listview SQLite BaseExpandableListAdapter 图片切割 bitmap
可以向QQ好友列表一样,可以有二级列表,使用的是android控件BaseExpandableListAdapter。
主要介绍了Android基于BaseExpandableListAdapter实现的二级列表仿通话记录功能,结合具体实例形式分析了Android实现通话记录功能的布局与功能相关操作技巧,需要的朋友可以参考下
import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListAdapter; import android.widget.ExpandableListView; import android.widget.TextView; import android.widget.Toast; ...
利用ExpandableListView实现多级目录的显示。
创建ExpandableListView并使用BaseExpandableListAdapter派生类填充它
好友列表的一个小例子,使用BaseExpandableListAdapter,完成的资源的复用,很简单很漂亮的例子
下面小编就为大家带来一篇Android 关于ExpandableListView刷新问题的解决方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
2、ANDROID应用程序结构 11 2.1、ACTIVITY 12 2.1.1、概述 12 2.1.2、Activity的生命周期 15 2.1.3、Activity 的创建 16 2.1.4、Activity 的跳转(含Bundle传值) 17 2.1.5.Actvity 堆栈 18 2.1.6、Intent对象调用...
在某些android开发群里,看到有些新手问怎么实现QQ好友列表,其实网上一搜挺多的。接触Android,也才一年的时间,大部分时间花在工作上(解bug。。。),界面上开发很少参与。自己维护的系统应用里,有个...
2、ANDROID应用程序结构 11 2.1、ACTIVITY 12 2.1.1、概述 12 2.1.2、Activity的生命周期 15 2.1.3、Activity 的创建 16 2.1.4、Activity 的跳转(含Bundle传值) 17 2.1.5.Actvity 堆栈 18 2.1.6、Intent对象调用...
使用ExpandableListAdapter实现购物车产品列表,然后通过CheckBox来选择产品。 弹出Layout来选择数量。值得产考!