ListView之BaseExpandableListAdapter
来源:互联网 发布:电梯安全员考试软件 编辑:程序博客网 时间:2024/06/05 15:32
BaseExpandableListAdapter主要用于类似于qq分组这样的显示的适配器
BaseExpandableListAdapteview适用于类似qq分组的模式
//关键代码是这个可扩展的listview适配器class ExAdapter extends BaseExpandableListAdapter {Context context;public ExAdapter(Context context) {super();this.context = context;}//得到大组成员总数public int getGroupCount() {// TODO Auto-generated method stubreturn groupData.size();}//得到小组成员总数public int getChildrenCount(int groupPosition) {// TODO Auto-generated method stubreturn childData.get(groupPosition).size();}//得到大组成员名称public Object getGroup(int groupPosition) {// TODO Auto-generated method stubreturn groupData.get(groupPosition).get(GROUP_TEXT).toString();}//得到小组成员名称public Object getChild(int groupPosition, int childPosition) {// TODO Auto-generated method stubreturn childData.get(groupPosition).get(childPosition).get(CHILD_NAME).toString();}//得到大组成员的idpublic long getGroupId(int groupPosition) {// TODO Auto-generated method stubreturn groupPosition;}//得到小组成员的idpublic long getChildId(int groupPosition, int childPosition) {// TODO Auto-generated method stubreturn childPosition;} /** * Indicates whether the child and group IDs are stable across changes * to the underlying data. 表明大組和小组id是否稳定的更改底层数据。 * * @return whether or not the same ID always refers to the same object * @see Adapter#hasStableIds() */public boolean hasStableIds() {// TODO Auto-generated method stubreturn true;}//得到大组成员的viewpublic View getGroupView(int groupPosition, boolean isExpanded,View convertView, ViewGroup parent) {// TODO Auto-generated method stubView view = convertView;if(view == null) {LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);view = inflater.inflate(R.layout.member_listview2, null);}TextView title = (TextView)view.findViewById(R.id.content_001);title.setText(getGroup(groupPosition).toString()); //设置最大组成员名称ImageView image = (ImageView)view.findViewById(R.id.tubiao); //是否展开大组的图标if(isExpanded) //大组展开时image.setBackgroundResource(R.drawable.hero);elseimage.setBackgroundResource(R.drawable.ic_launcher);return view;}//得到小组成员的viewpublic View getChildView(int groupPosition, int childPosition,boolean isLastChild, View convertView, ViewGroup parent) {// TODO Auto-generated method stubView view = convertView;if(view == null) {LayoutInflater inflater = LayoutInflater.from(context);view = inflater.inflate(R.layout.member_childitem2, null);}final TextView title = (TextView)view.findViewById(R.id.child_name);title.setText(childData.get(groupPosition).get(childPosition).get(CHILD_NAME).toString()); //大标题final TextView title2 = (TextView)view.findViewById(R.id.child_text);title2.setText(childData.get(groupPosition).get(childPosition).get(CHILD_TEXT).toString()); //小标题return view;}//得到小组成员是否被选择public boolean isChildSelectable(int groupPosition, int childPosition) {// TODO Auto-generated method stubreturn true;}}
0 0
- ListView之BaseExpandableListAdapter
- Android开发ListView之BaseExpandableListAdapter
- BaseExpandableListAdapter
- BaseExpandableListAdapter
- BaseExpandableListAdapter
- Android之BaseExpandableListAdapter的用法
- Android成长之路-BaseExpandableListAdapter的用法
- Android成长之路-BaseExpandableListAdapter的用法
- android 适配器Adpter的使用总结 之 BaseExpandableListAdapter
- Android之BaseExpandableListAdapter使用心得(QQ续一)
- Android之BaseExpandableListAdapter使用心得(QQ续一)
- android之expandableListView+BaseExpandableListAdapter+ArrayList伸缩的用法:
- Android之ExpandableList扩展用法(基于BaseExpandableListAdapter)
- Android BaseExpandableListAdapter
- Android BaseExpandableListAdapter
- Android BaseExpandableListAdapter
- BaseExpandableListAdapter封装
- Android开发之ExpandableListView扩展(BaseExpandableListAdapter的使用)(完整版)
- 我的第一个GitHub开源练习项目-OuNews新闻阅读软件(求Star求Fork_(:з」∠)_)
- eclipse里的Ctrl操作很慢
- Appium小试
- C#复合控件获取值,及事件一处理顺顺序
- [linux]查看mysql的配置文件及查看mysql端口
- ListView之BaseExpandableListAdapter
- 正则表达式二 :re.findall()和元字符
- 对composer的安装
- 关于Socket通信中多个线程同时向一个服务端口发送数据时的注意点
- 编写Android.mk终极技巧
- Nginx(tengine)添加mp4流媒体支持
- codeforces C. Famil Door and Brackets dp
- 随便说说
- iOS AFN AFNWorking3封装