二级列表购物车
2018-01-15 13:51
411 查看
一,依赖
compile 'com.squareup.okhttp3:okhttp:3.9.0' compile 'com.google.code.gson:gson:2.8.2' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.squareup.okhttp3:okhttp:3.2.0'二,权限
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
三,main 布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="ywf.bwei.com.gouwuche_lianxi.view.acativity.MainActivity"> <include layout="@layout/layout_title" /> <ExpandableListView android:id="@+id/expandList" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent"> </ExpandableListView> <View android:layout_width="match_parent" android:layout_height="0.5dp" android:layout_marginTop="2dp" android:background="#000000"/> <include layout="@layout/layout_bottom" /> </LinearLayout>
layout_title 的布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_red_light" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="返回" android:textSize="25sp" android:padding="10dp" android:textColor="@android:color/white" android:id="@+id/btnBack"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="25sp" android:padding="10dp" androi 251f3 d:textColor="@android:color/white" android:layout_weight="1" android:gravity="center" android:text="购物车"/> <TextView android:id="@+id/btnEditor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="编辑" android:textColor="@android:color/white" android:textSize="25sp" android:padding="10dp"/> </LinearLayout>
layout_bottom 的布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="全选" android:textSize="25sp" android:padding="10dp" android:id="@+id/btnCheckAll"/> <TextView android:id="@+id/tvTotalPrice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18sp" android:padding="10dp" android:textColor="@android:color/black" android:layout_weight="1" android:gravity="center" android:text="合计:¥0.00"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="结算(0)" android:textColor="@android:color/white" android:textSize="25sp" android:padding="10dp" android:background="@android:color/holo_red_light" android:id="@+id/btnAmount"/> </LinearLayout>layout_child_item 布局
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <CheckBox android:id="@+id/ck_child_choose" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:scaleX="0.6" android:scaleY="0.6" /> <ImageView android:id="@+id/iv_show_pic" android:layout_width="70dp" android:layout_height="80dp" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:src="@mipmap/ic_launcher" android:layout_toRightOf="@id/ck_child_choose" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="15dp" android:layout_toRightOf="@id/iv_show_pic" android:orientation="vertical"> <TextView android:id="@+id/tv_commodity_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="酒红色纯红色纯羊毛西服套装" android:textColor="@android:color/black" android:textSize="12sp" android:textStyle="bold" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/tv_commodity_attr" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="3dp" android:text="属性:粉蓝色" android:textSize="12sp" android:textColor="@color/colorPrimary" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:orientation="horizontal"> <TextView android:id="@+id/tv_commodity_price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="¥390" android:textColor="@android:color/holo_red_dark" android:textSize="12sp" android:textStyle="bold" /> <TextView android:id="@+id/tv_commodity_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="x1" android:textColor="@android:color/darker_gray" /> <LinearLayout android:id="@+id/rl_edit" android:layout_width="120dp" android:background="@android:color/holo_orange_light" android:layout_height="30dp" android:layout_marginLeft="20dp" > <TextView android:id="@+id/iv_sub" android:layout_width="0dp" android:layout_weight="1" android:gravity="center" android:textColor="@android:color/black" android:background="@android:color/white" android:layout_margin="1dp" android:layout_height="match_parent" android:text=" - " /> <TextView android:id="@+id/tv_commodity_show_num" android:layout_width="0dp" android:layout_weight="1" android:gravity="center" android:background="@android:color/white" android:layout_margin="1dp" android:layout_height="match_parent" android:text="1" /> <TextView android:id="@+id/iv_add" android:layout_width="0dp" android:layout_weight="1" android:gravity="center" android:layout_margin="1dp" android:background="@android:color/white" android:layout_height="match_parent" android:text=" + " /> </LinearLayout> </LinearLayout> </LinearLayout> <Button android:id="@+id/btn_commodity_delete" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:gravity="center" android:text="x" android:background="@android:color/holo_blue_light" android:textSize="20sp" android:textColor="@android:color/holo_green_dark" android:layout_margin="5dp" android:visibility="gone" /> </RelativeLayout>
layout_group_item 布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <CheckBox android:id="@+id/ck_group_choosed" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="商家1" android:gravity="center_vertical" android:textSize="25sp" android:focusable="false" android:padding="10dp"/> </LinearLayout>四,创建 view , model , persenter , bean ,adapter包 创建 view ,model , persenter 的接口和类model 层的 IShoppCarModel 接口
public interface IShoppCarModel { // IShooppPrensenter iShooppPrensenter是P层的接口 void getCarInfo(String uid,IShooppPrensenter iShooppPrensenter); }
model 的 ShoppCarModel 的类
注意:这需要OkHttp封装的utils包
public class ShoppCarModel implements IShoppCarModel { //IShooppPrensenter iShooppPrensenter 是P层的接口 public void getCarInfo(String uid, final IShooppPrensenter iShooppPrensenter) { Map<String, String> params = new HashMap<>(); params.put("uid", uid); OkHttpUtils okHttpUtils = OkHttpUtils.getInstance(); okHttpUtils.doGet(Constants.GET_CARTS, params, new OnFinishListener() { @Override public void onFailed(String msg) { iShooppPrensenter.onFailed(msg); } @Override public void onSuccess(Object obj) { //Gson解析 Gson gson = new Gson(); ShoppCarBean shoppCarBean = gson.fromJson(obj.toString(), ShoppCarBean.class); iShooppPrensenter.onSuccess(shoppCarBean.getData()); } }); } }
persenter 层的 IShooppPrensenter 接口
public interface IShooppPrensenter {void onSuccess(List<ShoppCarBean.DataBean> data); //是bean里面的List集合void onFailed(String msg);void onDestory();void getCarInfo(String uid);}
persenter 层的 ShooppPresenter 的类
public class ShooppPresenter implements IShooppPrensenter {//需要model层的接口private IShoppCarModel IShoppCarModel;private IMainView iMainView;//需要从P层传到V层public ShooppPresenter(IMainView iMainView) {this.iMainView = iMainView;//需要model层的接口IShoppCarModel = new ShoppCarModel();}@Overridepublic void getCarInfo(String uid) {IShoppCarModel.getCarInfo(uid, this);}@Overridepublic void onSuccess(List<ShoppCarBean.DataBean> data) {if (iMainView != null) {iMainView.onSuccess(data);}}@Overridepublic void onFailed(String msg) {if (iMainView != null) {iMainView.onFailed(msg);}}@Overridepublic void onDestory() {if (iMainView != null) {iMainView = null;}}}view 层的 IMainView 的接口
public interface IMainView {void onSuccess(List<ShoppCarBean.DataBean> data);void onFailed(String msg);}
bean 包的 ShoppCarBean
public class ShoppCarBean {/*** msg : 请求成功*/private String msg;private String code;private List<DataBean> data;public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public String getCode() {return code;}public void setCode(String code) {this.code = code;}public List<DataBean> getData() {return data;}public void setData(List<DataBean> data) {this.data = data;}public static class DataBean {/*** sellerName : 商家1* sellerid : 1*/private String sellerName;private String sellerid;private List<ListBean> list;//商家是否被选中 组条目是否被选中private boolean isGroupChoosed;public boolean isGroupChoosed() {return isGroupChoosed;}public void setGroupChoosed(boolean groupChoosed) {isGroupChoosed = groupChoosed;}//截止到上面public String getSellerName() {return sellerName;}public void setSellerName(String sellerName) {this.sellerName = sellerName;}public String getSellerid() {return sellerid;}public void setSellerid(String sellerid) {this.sellerid = sellerid;}public List<ListBean> getList() {return list;}public void setList(List<ListBean> list) {this.list = list;}public static class ListBean {/****/private double bargainPrice;private String createtime;private String detailUrl;private String images;private int num;private int pid;private double price;private int pscid;private int selected;private int sellerid;private String subhead;private String title;//子条目商品是否被选中的一个字段状态private boolean isChildChoosed;public boolean isChildChoosed() {return isChildChoosed;}public void setChildChoosed(boolean childChoosed) {isChildChoosed = childChoosed;}//截止到上面public double getBargainPrice() {return bargainPrice;}public void setBargainPrice(double bargainPrice) {this.bargainPrice = bargainPrice;}public String getCreatetime() {return createtime;}public void setCreatetime(String createtime) {this.createtime = createtime;}public String getDetailUrl() {return detailUrl;}public void setDetailUrl(String detailUrl) {this.detailUrl = detailUrl;}public String getImages() {return images;}public void setImages(String images) {this.images = images;}public int getNum() {return num;}public void setNum(int num) {this.num = num;}public int getPid() {return pid;}public void setPid(int pid) {this.pid = pid;}public double getPrice() {return price;}public void setPrice(double price) {this.price = price;}public int getPscid() {return pscid;}public void setPscid(int pscid) {this.pscid = pscid;}public int getSelected() {return selected;}public void setSelected(int selected) {this.selected = selected;}public int getSellerid() {return sellerid;}public void setSellerid(int sellerid) {this.sellerid = sellerid;}public String getSubhead() {return subhead;}public void setSubhead(String subhead) {this.subhead = subhead;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}}}}
adapter 包下 MyExpandAdapter 的类
public class MyExpandAdapter extends BaseExpandableListAdapter {private List<ShoppCarBean.DataBean> data;private Context context;//商品加减的一个接口变量 是在下面定义的接口private ModifyGoodsItemNumberListener modifyGoodsItemNumberListener;private CheckGroupItemListener checkGroupItemListener;//接收是否处于编辑状态的一个boolean值private boolean isEditor;public MyExpandAdapter(Context context) {this.context = context;}//设置数据public void setList(List<ShoppCarBean.DataBean> data) {this.data = data;notifyDataSetChanged();}//商家以及商品是否被选中的一个监听public void setCheckGroupItemListener(CheckGroupItemListener checkGroupItemListener) {this.checkGroupItemListener = checkGroupItemListener;}//设置商品的加减监听public void setModifyGoodsItemNumberListener(ModifyGoodsItemNumberListener modifyGoodsItemNumberListener) {this.modifyGoodsItemNumberListener = modifyGoodsItemNumberListener;}//是否显示删除按钮public void showDeleteButton(boolean isEditor) {this.isEditor = isEditor;//刷新适配器notifyDataSetChanged();}@Overridepublic int getGroupCount() {return data != null ? data.size() : 0;}@Overridepublic int getChildrenCount(int groupPosition) {return data != null && data.get(groupPosition).getList() != null ? data.get(groupPosition).getList().size() : 0;}@Overridepublic Object getGroup(int groupPosition) {return data.get(groupPosition);}@Overridepublic Object getChild(int groupPosition, int childPosition) {return data.get(groupPosition).getList().get(childPosition);}@Overridepublic long getGroupId(int groupPosition) {return groupPosition;}@Overridepublic long getChildId(int groupPosition, int childPosition) {return childPosition;}@Overridepublic boolean hasStableIds() {return false;}@Overridepublic View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {if (convertView == null) {convertView = LayoutInflater.from(context).inflate(R.layout.layout_group_item, parent, false);}CheckBox ck_group_choosed = convertView.findViewById(R.id.ck_group_choosed);//isGroupChoosed 需要在bean定义if (data.get(groupPosition).isGroupChoosed()) {ck_group_choosed.setChecked(true);} else {ck_group_choosed.setChecked(false);}ck_group_choosed.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {checkGroupItemListener.checkGroupItem(groupPosition, ((CheckBox) v).isChecked());}});//getSellerName 需要在bean定义ck_group_choosed.setText(data.get(groupPosition).getSellerName());return convertView;}@Overridepublic View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {if (convertView == null) {convertView = LayoutInflater.from(context).inflate(R.layout.layout_child_item, parent, false);}//商品选择CheckBox ck_child_choosed = convertView.findViewById(R.id.ck_child_choose);//商品图片ImageView iv_show_pic = convertView.findViewById(R.id.iv_show_pic);//商品主标题TextView tv_commodity_name = convertView.findViewById(R.id.tv_commodity_name);//商品副标题TextView tv_commodity_attr = convertView.findViewById(R.id.tv_commodity_attr);//商品价格TextView tv_commodity_price = convertView.findViewById(R.id.tv_commodity_price);//商品数量TextView tv_commodity_num = convertView.findViewById(R.id.tv_commodity_num);//商品减TextView iv_sub = convertView.findViewById(R.id.iv_sub);//商品加减中的数量变化final TextView tv_commodity_show_num = convertView.findViewById(R.id.tv_commodity_show_num);//商品加TextView iv_add = convertView.findViewById(R.id.iv_add);//删除按钮Button btn_commodity_delete = convertView.findViewById(R.id.btn_commodity_delete);//设置文本信息tv_commodity_name.setText(data.get(groupPosition).getList().get(childPosition).getTitle());tv_commodity_attr.setText(data.get(groupPosition).getList().get(childPosition).getSubhead());tv_commodity_price.setText("¥" + data.get(groupPosition).getList().get(childPosition).getPrice());tv_commodity_num.setText("x" + data.get(groupPosition).getList().get(childPosition).getNum());tv_commodity_show_num.setText(data.get(groupPosition).getList().get(childPosition).getNum() + "");//分割图片地址String images = data.get(groupPosition).getList().get(childPosition).getImages();String[] urls = images.split("\\|");//加载商品图片Glide.with(context).load(urls[0]).crossFade().into(iv_show_pic);//商品加iv_add.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {modifyGoodsItemNumberListener.doIncrease(groupPosition, childPosition, tv_commodity_show_num);}});//设置商品加减的按钮//商品减iv_sub.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {modifyGoodsItemNumberListener.doDecrease(groupPosition, childPosition, tv_commodity_show_num);}});//商品复选框是否被选中ck_child_choosed.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {checkGroupItemListener.checkChildItem(groupPosition, childPosition, ((CheckBox) v).isChecked());}});//处理商品的选中状态//isChildChoosed 需要在bean定义if (data.get(groupPosition).getList().get(childPosition).isChildChoosed()) {ck_child_choosed.setChecked(true);} else {ck_child_choosed.setChecked(false);}//控制删除按钮的隐藏与显示/*if(isEditor){btn_commodity_delete.setVisibility(View.VISIBLE);}else{btn_commodity_delete.setVisibility(View.GONE);}*/return convertView;}@Overridepublic boolean isChildSelectable(int groupPosition, int childPosition) {return false;}/*** 商家的复选框以及商品的复选框是否被选中的接口*//*** 商家复选框以及商品复选框是否被选中接口*/public interface CheckGroupItemListener {//商家的条目的复选框监听void checkGroupItem(int groupPosition, boolean isChecked);//商品的void checkChildItem(int groupPosition, int childPosition, boolean isChecked);}/*** 商品加减接口*/public interface ModifyGoodsItemNumberListener {//商品添加操作void doIncrease(int groupPosition, int childPosition, View view);//商品减少操作void doDecrease(int groupPosition, int childPosition, View view);}}
mian 主方法
public class MainActivity extends AppCompatActivity implements IMainView, MyExpandAdapter.ModifyGoodsItemNumberListener, MyExpandAdapter.CheckGroupItemListener {private ExpandableListView expandList;private CheckBox btnCheckAll;private TextView tvTotalPrice;private TextView btnAmount;private TextView btnEditor;private MyExpandAdapter adapter;private IShooppPrensenter iShooppPrensenter;private List<ShoppCarBean.DataBean> list;//购买商品的总数量private int totalNum = 0;//购买商品的总价private double totalPrice = 0.00;private boolean flag;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//隐藏actionbargetSupportActionBar().hide();expandList = (ExpandableListView) findViewById(R.id.expandList);//购物车底部栏的全选框btnCheckAll = (CheckBox) findViewById(R.id.btnCheckAll);//合计,计算总价tvTotalPrice = (TextView) findViewById(R.id.tvTotalPrice);//结算按钮btnAmount = (TextView) findViewById(R.id.btnAmount);//找到编辑控件btnEditor = (TextView) findViewById(R.id.btnEditor);//去除默认指示器expandList.setGroupIndicator(null);//设置适配器adapter = new MyExpandAdapter(this);expandList.setAdapter(adapter);//获取购物车信息iShooppPrensenter = new ShooppPresenter(this);iShooppPrensenter.getCarInfo("10192");//设置商品加减的监听adapter.setModifyGoodsItemNumberListener(this);//设置商家以及商品是否被选中的监听adapter.setCheckGroupItemListener(this);//全选的点击btnCheckAll.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {//isChoosedAll 在下面定义的 全选与反选isChoosedAll(((CheckBox) view).isChecked());//计算商品总价//statisticsPrice 在下面定义的计算你所选中的商品总价statisticsPrice();}});//编辑/*btnEditor.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {if(!flag){//编辑 -> 完成\flag = true;btnEditor.setText("完成");adapter.showDeleteButton(flag);}else{flag = false;btnEditor.setText("编辑");adapter.showDeleteButton(flag);}}});*/}//二级列表默认展开private void defaultExpand() {for (int i = 0; i < adapter.getGroupCount(); ++i) {expandList.expandGroup(i);}}@Overridepublic void onSuccess(List<ShoppCarBean.DataBean> data) {this.list = data;//设置数据adapter.setList(list);defaultExpand();}@Overridepublic void onFailed(String msg) {}@Overridepublic void checkGroupItem(int groupPosition, boolean isChecked) {//Toast.makeText(this, "商家", Toast.LENGTH_SHORT).show();//商家javabeanShoppCarBean.DataBean dataBean = list.get(groupPosition);dataBean.setGroupChoosed(isChecked);//遍历商家里面的商品,将其置为选中状态for (ShoppCarBean.DataBean.ListBean listBean : dataBean.getList()) {listBean.setChildChoosed(isChecked);}//底部结算那个checkbox状态(全选)// isCheckAll 是在下面定义的 购物车商品是否全部选中if (isCheckAll()) {btnCheckAll.setChecked(true);} else {btnCheckAll.setChecked(false);}//刷新适配器adapter.notifyDataSetChanged();//计算价格statisticsPrice();}@Overridepublic void checkChildItem(int groupPosition, int childPosition, boolean isChecked) {//Toast.makeText(this, "商品", Toast.LENGTH_SHORT).show();//ShoppCarBean.DataBean.ListBean listBean = list.get(groupPosition).getList().get(childPosition);ShoppCarBean.DataBean dataBean = list.get(groupPosition);//商家那一层List<ShoppCarBean.DataBean.ListBean> listBeans = dataBean.getList();ShoppCarBean.DataBean.ListBean listBean = listBeans.get(childPosition);//你点击商家的商品条目将其选中状态记录listBean.setChildChoosed(isChecked);//检测商家里面的每一个商品是否被选中,如果被选中,返回boolean// isGoodsCheckAll 是在下面检测某个商家的商品是否都选中,如果都选中的话,商家CheckBox应该是选中状态boolean result = isGoodsCheckAll(groupPosition);if (result) {dataBean.setGroupChoosed(result);} else {dataBean.setGroupChoosed(result);}//底部结算那个checkbox状态(全选)if (isCheckAll()) {btnCheckAll.setChecked(true);} else {btnCheckAll.setChecked(false);}//刷新适配器adapter.notifyDataSetChanged();//计算总价statisticsPrice();}@Overridepublic void doIncrease(int groupPosition, int childPosition, View view) {//Toast.makeText(this, "用户点击了商品减少操作", Toast.LENGTH_SHORT).show();ShoppCarBean.DataBean.ListBean listBean = list.get(groupPosition).getList().get(childPosition);//取出当前的商品数量int currentNum = listBean.getNum();currentNum++;listBean.setNum(currentNum);//刷新适配器adapter.notifyDataSetChanged();//计算商品价格statisticsPrice();}@Overridepublic void doDecrease(int groupPosition, int childPosition, View view) {//Toast.makeText(this, "用户点击了商品减少操作", Toast.LENGTH_SHORT).show();ShoppCarBean.DataBean.ListBean listBean = list.get(groupPosition).getList().get(childPosition);//取出当前的商品数量int currentNum = listBean.getNum();//直接结束这个方法if (currentNum == 1) {return;}currentNum--;listBean.setNum(currentNum);//刷新适配器adapter.notifyDataSetChanged();//计算商品价格statisticsPrice();}//全选与反选private void isChoosedAll(boolean isChecked) {for (ShoppCarBean.DataBean dataBean : list) {dataBean.setGroupChoosed(isChecked);for (ShoppCarBean.DataBean.ListBean listBean : dataBean.getList()) {listBean.setChildChoosed(isChecked);}}//刷新适配器adapter.notifyDataSetChanged();}/*** 计算你所选中的商品总价*/private void statisticsPrice() {//初始化值totalNum = 0;totalPrice = 0.00;for (ShoppCarBean.DataBean dataBean : list) {for (ShoppCarBean.DataBean.ListBean listBean : dataBean.getList()) {if (listBean.isChildChoosed()) {totalNum++;System.out.println("number : " + totalNum);totalPrice += listBean.getNum() * listBean.getPrice();}}}//设置文本信息 合计、结算的商品数量tvTotalPrice.setText("合计:¥" + totalPrice);btnAmount.setText("结算(" + totalNum + ")");}//购物车商品是否全部选中private boolean isCheckAll() {for (ShoppCarBean.DataBean dataBean : list) {if (!dataBean.isGroupChoosed()) {return false;}}return true;}//检测某个商家的商品是否都选中,如果都选中的话,商家CheckBox应该是选中状态private boolean isGoodsCheckAll(int groupPosition) {List<ShoppCarBean.DataBean.ListBean> listBeans = this.list.get(groupPosition).getList();//遍历某一个商家的每个商品是否被选中for (ShoppCarBean.DataBean.ListBean listBean : listBeans) {if (listBean.isChildChoosed()) {//是选中状态continue;} else {return false;}}return true;}}
相关文章推荐
- android二级列表显示购物车
- 安卓二级列表购物车 略屌略屌 一个类足矣
- 二级列表RecyclerView购物车
- 购物车二级列表
- Andriodjie——二级列表实现购物车
- Android 二级列表仿京东购物车 《H》
- 购物车二级列表
- Android 二级列表购物车
- Android实现二级列表购物车功能
- RecyclerView 购物车 二级列表
- 二级列表购物车okhttp(完整版)
- 购物车需要的内容(二级列表、封装工具类)
- 二级列表购物车
- andriod——二级列表完美实现购物车
- App中二级列表购物车的简单实现,查,删,改的功能
- Android电商项目 ExpandableListView(二级列表)实现购物车(高仿淘宝) demo
- RecyclerView 购物车 二级列表
- 模仿京东购物车(二级列表,mvp请求数据)
- Android仿京东App购物车 二级列表+全选反选+Ok封装+拦截器+结算+商品数量计算
- 购物车的二级列表适配器