1.先写布局
<ExpandableListView
android:id="@+id/elv"
android:layout_above="@+id/lin_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></ExpandableListView>
<LinearLayout
android:id="@+id/lin_end"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<CheckBox
android:id="@+id/all"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/all_count"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="合计:0"
android:gravity="center"
/>
<TextView
android:id="@+id/all_money"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="计算:0"
android:gravity="center"
/>
</LinearLayout>
2.导library
3.创建jsonbean类
4. 购物车
for (int i=0;i<data.size();i++){
flist.add(new GroupBean(data.get(i).getTitle(),false));
List<ChildBean> slist=new ArrayList<>();
for (int j=0;j<flist.size();j++){
slist.add(new ChildBean(data.get(j).getTitle(),data.get(j).getPrice()+"",data.get(j).getImages(),false,1));
}
clist.add(slist);
}
CartUtils.setCartData(MainActivity.this,flist,clist,elv,all,all_count,all_money);