ExpandableListView
来源:互联网 发布:c语言fprintf %s错误 编辑:程序博客网 时间:2024/06/05 22:46
ExpandableListView属性
exListView.expandGroup(i); //默认展开
exListView.setGroupIndicator(null); //去掉默认的箭头
exListView.setOnGroupClickListener(this); //重写父类的点击事件
在 BaseExpandableListAdapter 中 isExpanded 是用来判断 ExpandableListVIew 是打开还是关闭
ExpandableListView效果图
BaseExpandableListAdapter 代码:
public class GoogleMapExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
List<List<MenuBean>> datas;
public GoogleMapExpandableListAdapter(Context context) {
this.context = context;
datas = new ArrayList<List<MenuBean>>();
datas.add(MenuBean.initMenus());
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View converView, ViewGroup parent) {
TitleHolder titleHolder = null;
if (converView != null) {
titleHolder = (TitleHolder) converView.getTag();
} else {
titleHolder = new TitleHolder();
converView = View.inflate(context, R.layout.act_google_map_title, null);
titleHolder.title_content = (TextView) converView.findViewById(R.id.tv_title);
converView.setTag(titleHolder);
}
titleHolder.title_content.setText("Layer");
return converView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ContentHolder contentHolder = null;
if (convertView != null) {
contentHolder = (ContentHolder) convertView.getTag();
} else {
contentHolder = new ContentHolder();
convertView = View.inflate(context, R.layout.act_google_map_content, null);
contentHolder.content_icon = (ImageView) convertView.findViewById(R.id.iv_content_icon);
contentHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
contentHolder.check_box = (CheckBox) convertView.findViewById(R.id.content_check_box);
convertView.setTag(contentHolder);
}
final MenuBean bean = datas.get(groupPosition).get(childPosition);
contentHolder.tv_content.setText(bean.title);
contentHolder.content_icon.setImageResource(bean.icon);
contentHolder.check_box.setChecked(bean.status);
return convertView;
}
@Override
public int getGroupCount() {
return datas.size();
}
@Override
public int getChildrenCount(int groupPosition) {
return datas.get(groupPosition).size();
}
@Override
public Object getGroup(int groupPosition) {
return datas.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return datas.get(groupPosition).get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
class TitleHolder {
ImageView title_icon;
TextView title_content;
ImageView title_image;
}
class ContentHolder {
ImageView content_icon;
TextView tv_content;
CheckBox check_box;
}
0 0
- ExpandableListView
- ExpandableListView
- ExpandableListView
- ExpandableListView
- ExpandableListView
- ExpandableListView
- expandableListView
- ExpandableListView
- expandablelistview
- ExpandableListview
- ExpandableListView
- ExpandableListView
- ExpandableListView
- Expandablelistview
- ExpandableListView
- ExpandableListView
- ExpandableListView
- ExpandableListView
- 按法定v
- 24个扁平风格图标的PSD格式免费下载
- Mapping Designer里实用autolink提高效率
- utf-8编码出错iis错误提示乱码解决方法
- 【COM原理和应用】3、COM的实现
- ExpandableListView
- 设计模式【转载】
- 排兵布阵&&线段树
- 51单片机 28BYJ-48步进电机的细分驱动方式 Test
- 前端开发思路
- 微信营销效果如何衡量 转载
- 黑幕背后的Autorelease
- Android ellipsize的几种属性值介绍
- stm32 pwm频率从2K到4K