前面有篇文章实现了Android 简单的购物车 这篇实现了购物车中商品按照店铺分类显示的 也就是淘宝购物车的显示方式。
主要代码
package com.jock.shopcart;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;
import com.jock.adapter.ShopcartExpandableListViewAdapter;
import com.jock.adapter.ShopcartExpandableListViewAdapter.CheckInterface;
import com.jock.adapter.ShopcartExpandableListViewAdapter.ModifyCountInterface;
import com.jock.entity.GroupInfo;
import com.jock.entity.ProductInfo;
import com.jock.shopcar.R;
public class MainActivity extends Activity implements CheckInterface, ModifyCountInterface, OnClickListener
{
private ExpandableListView exListView;
private CheckBox cb_check_all;
private TextView tv_total_price;
private TextView tv_delete;
private TextView tv_go_to_pay;
private Context context;
private double totalPrice = 0.00;// 购买的商品总价
private int totalCount = 0;// 购买的商品总数量
private ShopcartExpandableListViewAdapter selva;
private List<GroupInfo> groups = new ArrayList<GroupInfo>();// 组元素数据列表
private Map<String, List<ProductInfo>> children = new HashMap<String, List<ProductInfo