package com.baway.test;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;
import com.bwie.mycartutils.bean.ChildBean;
import com.bwie.mycartutils.bean.GroupBean;
import com.bwie.mycartutils.utils.CartUtils;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private ExpandableListView expandableListView;
private CheckBox checkBox;
private TextView sum,jiesuan;
private List<GroupBean> groupList;
private List<List<ChildBean>> cList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取控件
expandableListView = (ExpandableListView) findViewById(R.id.elv);
checkBox = (CheckBox) findViewById(R.id.allcheck);
sum = (TextView) findViewById(R.id.sum);
jiesuan = (TextView) findViewById(R.id.jiesuan);
//初始化数据
groupList = new ArrayList<>();
cList = new ArrayList<>();
for (int i = 0; i < 4; i++) {
groupList.add(new GroupBean("商家"+i,false));
List<ChildBean> clist = new ArrayList<>();
for (int j = 0; j < 4; j++) {
clist.add(new ChildBean("商品1","20","http://img3.imgtn.bdimg.com/it/u=2337557546,3853217561&fm=27&gp=0.jpg",false,1));
}
cList.add(clist);
}
CartUtils.setCartData(this,groupList,cList,expandableListView,checkBox,jiesuan,sum);
}
}
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;
import com.bwie.mycartutils.bean.ChildBean;
import com.bwie.mycartutils.bean.GroupBean;
import com.bwie.mycartutils.utils.CartUtils;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private ExpandableListView expandableListView;
private CheckBox checkBox;
private TextView sum,jiesuan;
private List<GroupBean> groupList;
private List<List<ChildBean>> cList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//获取控件
expandableListView = (ExpandableListView) findViewById(R.id.elv);
checkBox = (CheckBox) findViewById(R.id.allcheck);
sum = (TextView) findViewById(R.id.sum);
jiesuan = (TextView) findViewById(R.id.jiesuan);
//初始化数据
groupList = new ArrayList<>();
cList = new ArrayList<>();
for (int i = 0; i < 4; i++) {
groupList.add(new GroupBean("商家"+i,false));
List<ChildBean> clist = new ArrayList<>();
for (int j = 0; j < 4; j++) {
clist.add(new ChildBean("商品1","20","http://img3.imgtn.bdimg.com/it/u=2337557546,3853217561&fm=27&gp=0.jpg",false,1));
}
cList.add(clist);
}
CartUtils.setCartData(this,groupList,cList,expandableListView,checkBox,jiesuan,sum);
}
}