ExpandableList的用法
来源:互联网 发布:淘宝代销退货流程 编辑:程序博客网 时间:2024/05/01 17:36
public class ShoppingCarNewAdapter extends BaseExpandableListAdapter { private Context mCtx; private ArrayList<ShopcarParentBean> shopcarList = new ArrayList<ShopcarParentBean>(); private onParentSelectListener parentListener; private onItemSelectListener itemListener; public void setOnItemSelectListener(onItemSelectListener itemListener) { this.itemListener = itemListener; } public void setOnParentSelectListener(onParentSelectListener parentListener) { this.parentListener = parentListener; } public ShoppingCarNewAdapter(Context context, ArrayList<ShopcarParentBean> list) { this.mCtx = context; this.shopcarList = list; } public void adapterChange(ArrayList<ShopcarParentBean> list) { this.shopcarList = list; this.notifyDataSetChanged(); } @Override public Object getChild(int groupPosition, int childPosition) { // TODO Auto-generated method stub return shopcarList.get(groupPosition).getShopCarItem().get(childPosition); } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public View getChildView(final int groupPosition, final int position, boolean arg2, View view, ViewGroup arg4) { ChildViewHolder childVHolder = null; if (view == null) { view = LayoutInflater.from(mCtx).inflate(R.layout.adapter_shopping_car, null); childVHolder = new ChildViewHolder(view); view.setTag(childVHolder); } else { childVHolder = (ChildViewHolder) view.getTag(); } // 捆绑数据 final ShopcarBean shopcarBean = (ShopcarBean) getChild(groupPosition, position); childVHolder.costTv.setText(shopcarBean.getCash()); childVHolder.orderNoTv.setText(shopcarBean.getNum()); if (shopcarList.get(groupPosition).isSelect() || shopcarBean.isSelect()) { childVHolder.checkBox.setChecked(true); } else { childVHolder.checkBox.setChecked(false); } childVHolder.checkBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { CheckBox checkBox = (CheckBox) arg0; shopcarBean.setIsSelect(checkBox.isChecked()); if (itemListener != null) { itemListener.setItemSelect(shopcarBean, groupPosition); } } }); return view; } @Override public int getChildrenCount(int groupPosition) { // TODO Auto-generated method stub return shopcarList.get(groupPosition).getShopCarItem().size();// 二级分类的数量 } @Override public Object getGroup(int arg0) { return shopcarList.get(arg0); } @Override public int getGroupCount() { return shopcarList.size();// 一级分类的数量 } @Override public long getGroupId(int arg0) { return arg0; } @Override public View getGroupView(int postion, boolean arg1, View view, ViewGroup arg3) { ParentViewHolder parentVHolder = null; if (null == view) { view = LayoutInflater.from(mCtx).inflate(R.layout.adapter_shopping_car_parent, null); parentVHolder = new ParentViewHolder(view); view.setTag(parentVHolder); } else { parentVHolder = (ParentViewHolder) view.getTag(); } // 捆绑数据 final ShopcarParentBean bean = shopcarList.get(postion); parentVHolder.shopNameTv.setText(bean.getShopName()); parentVHolder.totalMoneyTv.setText(bean.getTotalMoney()); if (bean.isSelect()) { parentVHolder.parentCheckBox.setChecked(true); } else { parentVHolder.parentCheckBox.setChecked(false); } parentVHolder.parentCheckBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { CheckBox pBox = (CheckBox) arg0; bean.setIsSelect(pBox.isChecked()); if (parentListener != null) { parentListener.setParentSelect(bean); } } }); return view; } @Override public boolean hasStableIds() { // TODO Auto-generated method stub return true; } @Override public boolean isChildSelectable(int arg0, int arg1) { return true; } static class ParentViewHolder { @Bind(R.id.adapter_shopping_car_total_money) TextView totalMoneyTv; @Bind(R.id.adapter_shop_car_name) TextView shopNameTv; @Bind(R.id.adapter_shopping_car_parent_check_box) CheckBox parentCheckBox; public ParentViewHolder(View view) { ButterKnife.bind(this, view); } } static class ChildViewHolder { @Bind(R.id.adapter_shopping_car_orderno) TextView orderNoTv; @Bind(R.id.adapter_shopping_car_cost) TextView costTv; // @Bind(R.id.adapter_shopping_car_content_tv) // TextView contentTv; @Bind(R.id.adapter_shopping_car_check_box) CheckBox checkBox; public ChildViewHolder(View view) { ButterKnife.bind(this, view); } } public interface onParentSelectListener { public void setParentSelect(ShopcarParentBean shopCar); } public interface onItemSelectListener { public void setItemSelect(ShopcarBean shopCar, int parentPos); }}
0 0
- ExpandableList的用法
- Android ExpandableList扩展用法
- ExpandableList扩展用法
- ExpandableList
- expandablelist
- android ExpandableList的自动收起
- ExpandableList------可扩展的list
- ExpandableList列表的简单应用
- 简单的ExpandableList控件例子
- 定制自己的ExpandableList(实现checkable)
- android-ExpandableList可展开的list
- Android常用控件之ExpandableList的使用
- Android之ExpandableList扩展用法(基于BaseExpandableListAdapter)
- android,ExpandableList,将被选中的group置于顶端
- 安卓实现ExpandableList中子项不同的布局
- ExpandableList 点击无法展开的原因及解决方案
- 自定义ExpandableList
- Adapter类控件使用之ExpandableList(可折叠式列表)的基本使用
- 279. Perfect Squares
- Linux6 fo OracleRAC install
- 枚举BootDriverReinitialization
- URL优化之IIS7如何开启伪静态
- cas-单点登录逻辑模拟学习
- ExpandableList的用法
- LightOJ-1198-greedy
- nginx+keepalived+tomcat+memcached服务器集群搭建
- 【HNOI2004】 敲砖块 动态规划
- 第十二周--项目4-利用遍历思想求解图问题(1)-(5)
- 【军工科技】2016年珠海航展 - 中国歼20隐形战机首秀
- 复杂网络基础知识--图的各种距离定义
- Linux6配置网络
- 扫盲cpc和cpt