Android--购物车接口删除

来源:互联网 发布:哪里买淘宝小号 编辑:程序博客网 时间:2024/06/07 03:26

//权限:

 <uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
//依赖:

  compile 'com.github.bumptech.glide:glide:3.6.0'    compile 'com.jakewharton:butterknife:8.8.1'    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'    compile 'io.reactivex.rxjava2:rxjava:2.1.1'    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'    compile 'com.squareup.retrofit2:retrofit:2.0.0'    compile 'com.squareup.retrofit2:converter-gson:2.0.2'    compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
Bean类:

CarBean
public class CarBean {    /**     * msg : 请求成功     * code : 0     * data : [{"list":[{"bargainPrice":1999,"createtime":"2017-10-10T16:09:02","detailUrl":"https://item.m.jd.com/product/5025971.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t7210/232/3738666823/232298/9004583e/59c3a9a7N8de42e15.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8356/82/2107423621/109733/c019b8c6/59c3a9a6Ne9a4bdd7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t10219/74/25356012/171379/7d55e296/59c3a9a8N82fa6e02.jpg!q70.jpg","num":1,"pid":49,"price":333,"pscid":39,"selected":0,"sellerid":5,"subhead":"vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!","title":"vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待"}],"sellerName":"商家5","sellerid":"5"}]     */    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 {        /**         * list : [{"bargainPrice":1999,"createtime":"2017-10-10T16:09:02","detailUrl":"https://item.m.jd.com/product/5025971.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t7210/232/3738666823/232298/9004583e/59c3a9a7N8de42e15.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8356/82/2107423621/109733/c019b8c6/59c3a9a6Ne9a4bdd7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t10219/74/25356012/171379/7d55e296/59c3a9a8N82fa6e02.jpg!q70.jpg","num":1,"pid":49,"price":333,"pscid":39,"selected":0,"sellerid":5,"subhead":"vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!","title":"vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待"}]         * sellerName : 商家5         * sellerid : 5         */        private String sellerName;        private String sellerid;        private List<ListBean> list;        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 {            /**             * bargainPrice : 1999.0             * createtime : 2017-10-10T16:09:02             * detailUrl : https://item.m.jd.com/product/5025971.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends             * images : https://m.360buyimg.com/n0/jfs/t7210/232/3738666823/232298/9004583e/59c3a9a7N8de42e15.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8356/82/2107423621/109733/c019b8c6/59c3a9a6Ne9a4bdd7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t10219/74/25356012/171379/7d55e296/59c3a9a8N82fa6e02.jpg!q70.jpg             * num : 1             * pid : 49             * price : 333.0             * pscid : 39             * selected : 0             * sellerid : 5             * subhead : vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!             * title : vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待             */            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;            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;            }        }    }}
Child
public class Child {    private boolean flag;    private String title;    private double price;    private String image;    private int unm;    private int pid;    public Child(boolean flag, String title, double price, String image, int unm,int pid) {        this.flag = flag;        this.title = title;        this.price = price;        this.image = image;        this.unm = unm;        this.pid = pid;    }    public int getPid() {        return pid;    }    public void setPid(int pid) {        this.pid = pid;    }    public boolean isFlag() {        return flag;    }    public void setFlag(boolean flag) {        this.flag = flag;    }    public String getTitle() {        return title;    }    public void setTitle(String title) {        this.title = title;    }    public double getPrice() {        return price;    }    public void setPrice(double price) {        this.price = price;    }    public String getImage() {        return image;    }    public void setImage(String image) {        this.image = image;    }    public int getUnm() {        return unm;    }    public void setUnm(int unm) {        this.unm = unm;    }}
Delete
  
public class Delete {    /**     * msg : 购物车数据不存在     * code : 1     */    private String    msg;    private String code;    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;    }}
一级列表店铺名:
Group
public class Group {    private boolean flag;    private String name;    public Group(boolean flag, String name) {        this.flag = flag;        this.name = name;    }    public boolean isFlag() {        return flag;    }    public void setFlag(boolean flag) {        this.flag = flag;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }}
IView
public interface IView {    void onSuccess(Object o);    void onFailed(Exception e);}
IModel
public interface IModel {    void get(String baseurl,Map<String,String> map);}

ApiService
public interface ApiService {    //http://120.27.23.105/product/getCarts    @GET("product/getCarts")    Flowable<CarBean> get(@QueryMap Map<String,String> map);    //http://120.27.23.105/product/deleteCart?source=android&uid=1653&pid=2    @GET("product/deleteCart")    Flowable<Delete> get2(@QueryMap Map<String,String> map);}

Model
public class Model implements IModel{    private Presenter presenter;    public Model(Presenter presenter) {        this.presenter = presenter;    }    @Override    public void get(String baseurl, Map<String, String> map) {        Flowable<CarBean> flowable = RetrofitUtils.getInstance(baseurl).getretrofit().create(ApiService.class).get(map);        presenter.getData(flowable);    }}

DModel
public class DModel implements IModel{    private DPresenter presenter;    public DModel(DPresenter presenter) {        this.presenter = presenter;    }    @Override    public void get(String baseurl, Map<String, String> map) {        Flowable<Delete> flowable = RetrofitUtils.getInstance(baseurl).getretrofit().create(ApiService.class).get2(map);        presenter.getData(flowable);    }}
BasePresenter
public interface BasePresenter {    void get(String baseurl,Map<String,String> map);}
DPresenter
public class DPresenter implements BasePresenter{    private IView iv;    private DisposableSubscriber<Delete> disposableSubscriber1;    public DPresenter(IView iv) {        this.iv = iv;    }    @Override    public void get(String baseurl, Map<String, String> map) {        DModel model = new DModel(this);        model.get(baseurl,map);    }    public void getData(Flowable<Delete> flowable){        disposableSubscriber1 = flowable.subscribeOn(Schedulers.io())                .observeOn(AndroidSchedulers.mainThread())                .subscribeWith(new DisposableSubscriber<Delete>() {                    @Override                    public void onNext(Delete delete) {                        iv.onSuccess(delete);                    }                    @Override                    public void onError(Throwable t) {                        iv.onFailed((Exception) t);                    }                    @Override                    public void onComplete() {                    }                });    }    //防止内存泄漏    public void detatch(){        if (iv != null) {            iv = null;        }        if(disposableSubscriber1!=null){            if(!disposableSubscriber1.isDisposed()){                disposableSubscriber1.dispose();            }        }    }}
Presenter
public class Presenter implements BasePresenter{   private IView iv;    private DisposableSubscriber<CarBean> disposableSubscriber;    public Presenter(IView iv) {        this.iv = iv;    }    @Override    public void get(String baseurl, Map<String, String> map) {        Model model = new Model(this);        model.get(baseurl,map);    }    public void getData(Flowable<CarBean> flowable){        disposableSubscriber = flowable.subscribeOn(Schedulers.io())                .observeOn(AndroidSchedulers.mainThread())                .subscribeWith(new DisposableSubscriber<CarBean>() {                    @Override                    public void onNext(CarBean carBean) {                        Log.e("TAG",carBean.getMsg());                        iv.onSuccess(carBean);                    }                    @Override                    public void onError(Throwable t) {                        iv.onFailed((Exception) t);                    }                    @Override                    public void onComplete() {                    }                });    }    //防止内存泄漏    public void detatch(){        if (iv != null) {            iv = null;        }        if(disposableSubscriber!=null){            if(!disposableSubscriber.isDisposed()){                disposableSubscriber.dispose();            }        }    }}

RetrofitUtils
public class RetrofitUtils {    private static volatile RetrofitUtils instance;    private final Retrofit retrofit;    private RetrofitUtils(String baseurl) {        retrofit = new Retrofit.Builder()                .baseUrl(baseurl)                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())                .addConverterFactory(GsonConverterFactory.create())                .build();    }    public static RetrofitUtils getInstance(String baseurl) {        if (instance == null) {            synchronized (RetrofitUtils.class) {                if (instance == null) {                    instance = new RetrofitUtils(baseurl);                }            }        }        return instance;    }    public Retrofit getretrofit(){        return retrofit;    }}
ShopAddDelete
public class ShopAddDelete extends RelativeLayout{    public TextView count;    public ShopAddDelete(Context context) {        this(context,null);    }    public ShopAddDelete(Context context, AttributeSet attrs) {        this(context, attrs,0);    }    public ShopAddDelete(Context context, AttributeSet attrs, int defStyleAttr) {        super(context, attrs, defStyleAttr);        initView(context, attrs, defStyleAttr);    }    private OnAddDeleteClickListener listener;    //对外提供一个点击的回调接口    public interface OnAddDeleteClickListener{        void onAddClick(View v);        void onDelClick(View v);    }    public void setOnAddDeleteClick(OnAddDeleteClickListener listener){        this.listener = listener;    }    private void initView(final Context context, AttributeSet attrs, int defStyleAttr) {        View view = View.inflate(context, R.layout.add_delete, this);        TextView delete = (TextView)view.findViewById(R.id.delete);        count = (TextView)view.findViewById(R.id.count);        TextView add = (TextView)view.findViewById(R.id.add);        delete.setOnClickListener(new OnClickListener() {            @Override            public void onClick(View view) {                listener.onDelClick(view);            }        });        add.setOnClickListener(new OnClickListener() {            @Override            public void onClick(View view) {                listener.onAddClick(view);            }        });    }    //对外提供设置EditText值的方法    public void setNumber(int number){        count.setText(number + "");    }    //得到控件原来的值,并转成int类型    public int getNumber(){        int number = Integer.parseInt(count.getText().toString().trim());        return number;    }}
MainActivity
public class MainActivity extends AppCompatActivity implements IView {    public static CheckBox checkbox;    @BindView(R.id.textView)    TextView textView;    @BindView(R.id.shop)    TextView shop;    @BindView(R.id.textView3)    TextView textView3;    @BindView(R.id.checkBox)    CheckBox checkBox;    @BindView(R.id.price)    TextView price;    @BindView(R.id.re)    RelativeLayout re;    @BindView(R.id.expandablelistview)    ExpandableListView expandablelistview;    @BindView(R.id.btn)    Button btn;    private List<Group> grouplist = new ArrayList<>();    private List<List<Child>> childlist = new ArrayList<>();    private ExpandAdapter expandAdapter;    private Presenter presenter;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        //http://120.27.23.105/product/getCarts?source=android&uid=1653        ButterKnife.bind(this);        checkbox = (CheckBox) findViewById(R.id.checkBox);        expandAdapter = new ExpandAdapter(this, grouplist, childlist);        expandablelistview.setAdapter(expandAdapter);        p();        textView3.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                if(textView3.getText().toString().trim().equals("编辑")){                    textView3.setText("完成");                    ExpandAdapter.q = 1;                    expandAdapter.notifyDataSetChanged();                }else{                    textView3.setText("编辑");                    ExpandAdapter.q = 0;                    expandAdapter.notifyDataSetChanged();                }            }        });    }    public void p() {        presenter = new Presenter(this);        Map<String, String> map = new HashMap();        map.put("source", "android");        map.put("uid", "1653");        presenter.get("http://120.27.23.105/", map);    }    public void js() {        double p = 0;        int s = 0;        for (int i = 0; i < childlist.size(); i++) {            for (int j = 0; j < childlist.get(i).size(); j++) {                if (childlist.get(i).get(j).isFlag()) {                    double price = childlist.get(i).get(j).getPrice();                    int num = childlist.get(i).get(j).getUnm();                    p += price * num;                    s++;                }            }        }        DecimalFormat df = new DecimalFormat("######0.00");        price.setText("总价:" + df.format(p));        btn.setText("去支付("+s+")");        shop.setText("购物车("+s+")");    }    @OnClick(R.id.checkBox)    public void onViewClicked() {        for (int i = 0; i < grouplist.size(); i++) {            grouplist.get(i).setFlag(checkBox.isChecked());        }        for (int i = 0; i < childlist.size(); i++) {            for (int j = 0; j < childlist.get(i).size(); j++) {                childlist.get(i).get(j).setFlag(checkBox.isChecked());            }        }        js();        expandAdapter.notifyDataSetChanged();    }    @Override    public void onSuccess(Object o) {        if (o != null) {            CarBean b = (CarBean) o;            List<CarBean.DataBean> data = b.getData();            for (int i = 0; i < data.size(); i++) {                grouplist.add(new Group(false, data.get(i).getSellerName()));                List<CarBean.DataBean.ListBean> list = data.get(i).getList();                List<Child> cl = new ArrayList<>();                for (int j = 0; j < list.size(); j++) {                    int pid = list.get(j).getPid();                    cl.add(new Child(false, list.get(j).getTitle(), (float) list.get(j).getPrice(), list.get(j).getImages(), list.get(j).getNum(),pid));                }                childlist.add(cl);            }            for (int s = 0; s < expandAdapter.getGroupCount(); s++) {                expandablelistview.expandGroup(s);            }            expandAdapter.notifyDataSetChanged();        }    }    @Override    public void onFailed(Exception e) {    }    @Override    protected void onDestroy() {        super.onDestroy();        if(presenter!=null){            presenter.detatch();        }    }}
ExpandAdapter
public class ExpandAdapter extends BaseExpandableListAdapter implements IView{    private Context context;    private List<Group> data1;    private List<List<Child>> data2;    public static int q = 0;    private Presenter presenter;    public ExpandAdapter(Context context, List<Group> data1, List<List<Child>> data2) {        this.context = context;        this.data1 = data1;        this.data2 = data2;    }    @Override    public int getGroupCount() {        return data1.size();    }    @Override    public int getChildrenCount(int i) {        return data2.get(i).size();    }    @Override    public Object getGroup(int i) {        return data1.get(i);    }    @Override    public Object getChild(int i, int i1) {        return data2.get(i).get(i1);    }    @Override    public long getGroupId(int i) {        return i;    }    @Override    public long getChildId(int i, int i1) {        return i1;    }    @Override    public boolean hasStableIds() {        return false;    }    @Override    public void onSuccess(Object o) {        data1.clear();        data2.clear();        Delete d = (Delete) o;        Toast.makeText(context,d.getMsg(),Toast.LENGTH_SHORT).show();        MainActivity m = (MainActivity) context;        m.p();    }    @Override    public void onFailed(Exception e) {    }    class ViewHolder{        CheckBox check;        TextView tv;    }    class ViewHolder2{        CheckBox check;        ImageView image;        TextView tv1,tv2;        ShopAddDelete ad;        Button button;    }    @Override    public View getGroupView(final int i, final boolean b, View view, ViewGroup viewGroup) {        final ViewHolder holder;        if(view==null){            holder = new ViewHolder();            view = View.inflate(context, R.layout.group_item,null);            holder.check = (CheckBox)view.findViewById(R.id.main_check_all);            holder.tv = (TextView)view.findViewById(R.id.textView3);            view.setTag(holder);        }else{            holder = (ViewHolder) view.getTag();        }        holder.tv.setText(data1.get(i).getName());        holder.check.setChecked(data1.get(i).isFlag());        holder.check.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                MainActivity m = (MainActivity) context;                //Group布尔值变成选中状态                data1.get(i).setFlag(holder.check.isChecked());                //遍历Group集合                for (int i = 0; i < data1.size(); i++) {                    //如果有一个未选中   全选变成false并跳出                    if(!data1.get(i).isFlag()){                        m.checkbox.setChecked(false);                        break;                    }else{//全部选中 全选变成true                        m.checkbox.setChecked(true);                    }                }                //Child集合布尔值为选中的状态                for (int j=0;j<data2.get(i).size();j++){                    data2.get(i).get(j).setFlag(holder.check.isChecked());                }                //刷新适配器                notifyDataSetChanged();                //调用计算的方法                m.js();            }        });        return view;    }    @Override    public View getChildView(final int i, final int i1, final boolean b, View view, ViewGroup viewGroup) {        final ViewHolder2 holder2;        if(view==null){            holder2 = new ViewHolder2();            view = View.inflate(context, R.layout.child_item,null);            holder2.check = (CheckBox)view.findViewById(R.id.main_check_all);            holder2.image = (ImageView)view.findViewById(R.id.imageView3);            holder2.tv1 = (TextView)view.findViewById(R.id.textView4);            holder2.tv2 = (TextView)view.findViewById(R.id.textView5);            holder2.ad = (ShopAddDelete)view.findViewById(R.id.ad);            holder2.button = (Button)view.findViewById(R.id.button);            view.setTag(holder2);        }else{            holder2 = (ViewHolder2) view.getTag();        }        if(q==0){            holder2.button.setVisibility(View.GONE);        }else{            holder2.button.setVisibility(View.VISIBLE);        }        String images = data2.get(i).get(i1).getImage();        String[] split = images.split("!");        Glide.with(context).load(split[0]).into(holder2.image);        holder2.tv1.setText(data2.get(i).get(i1).getTitle());        holder2.tv2.setText(data2.get(i).get(i1).getPrice()+"");        holder2.ad.count.setText(data2.get(i).get(i1).getUnm()+"");        holder2.check.setChecked(data2.get(i).get(i1).isFlag());        holder2.check.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                MainActivity m = (MainActivity) context;                //Child布尔值变成选中状态                data2.get(i).get(i1).setFlag(holder2.check.isChecked());                //遍历Ghild集合                for(int i=0;i<data2.size();i++){                    for(int j=0;j<data2.get(i).size();j++){                        //如果有一个未选中     全选与商家按钮变成false并跳出                        if(!data2.get(i).get(j).isFlag()){                            data1.get(i).setFlag(false);                            m.checkbox.setChecked(false);                            break;                        }else{//全部选中  全选与商家按钮变成true                            data1.get(i).setFlag(true);                            m.checkbox.setChecked(true);                        }                    }                }                //二次遍历                for(int i=0;i<data1.size();i++){                    boolean flag = data1.get(i).isFlag();                    if(flag){                        m.checkbox.setChecked(true);                    }else{                        m.checkbox.setChecked(false);                        break;                    }                }                notifyDataSetChanged();                //调用计算的方法                m.js();            }        });        holder2.button.setOnClickListener(new View.OnClickListener() {            private DPresenter dPresenter;            @Override            public void onClick(View view) {                //http://120.27.23.105/product/deleteCart?source=android&uid=1653&pid=2                dPresenter = new DPresenter(ExpandAdapter.this);                Map<String,String> map = new HashMap<String, String>();                map.put("source","android");                map.put("uid","1653");                map.put("pid",data2.get(i).get(i1).getPid()+"");                dPresenter.get("http://120.27.23.105/",map);            }        });        holder2.ad.setOnAddDeleteClick(new ShopAddDelete.OnAddDeleteClickListener() {            @Override            public void onAddClick(View v) {                MainActivity m = (MainActivity) context;                int number = holder2.ad.getNumber();                number++;                holder2.ad.setNumber(number);                Log.i("TAG",number+"");                data2.get(i).get(i1).setUnm(number);                notifyDataSetChanged();                //调用计算的方法                m.js();            }            @Override            public void onDelClick(View v) {                MainActivity m = (MainActivity) context;                int number = holder2.ad.getNumber();                number--;                if(number>0){                    holder2.ad.setNumber(number);                    data2.get(i).get(i1).setUnm(number);                }else{                    Toast.makeText(context,"最小数量为1",Toast.LENGTH_SHORT).show();                }                notifyDataSetChanged();                //调用计算的方法                m.js();            }        });        return view;    }    @Override    public boolean isChildSelectable(int i, int i1) {        return false;    }}
布局:
activity_main:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout    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" tools:context="com.bwei.MainActivity">    <TextView        android:text="〈"        android:layout_width="25dp"        android:layout_height="25dp"        android:textSize="20dp"        android:id="@+id/textView" />    <TextView        android:id="@+id/shop"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignBottom="@+id/textView"        android:layout_centerHorizontal="true"        android:text="购物车(0)"        android:textSize="20dp"/>    <TextView        android:id="@+id/textView3"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignBottom="@+id/shop"        android:layout_alignParentEnd="true"        android:layout_alignParentRight="true"        android:text="编辑"        android:textSize="20dp"/>    <View        android:background="#706a70"        android:layout_width="match_parent"        android:layout_height="1dp"        android:layout_below="@id/shop"/>    <RelativeLayout        android:id="@+id/re"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true">        <CheckBox            android:text="全选"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:id="@+id/checkBox" />        <TextView            android:id="@+id/price"            android:text="合计:0.00"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_centerVertical="true"            android:layout_centerHorizontal="true" />        <Button            android:id="@+id/btn"            android:text="去支付(0)"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentTop="true"            android:layout_alignParentRight="true"            android:layout_alignParentEnd="true" />    </RelativeLayout>    <ExpandableListView        android:id="@+id/expandablelistview"        android:layout_below="@id/shop"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_above="@id/re"></ExpandableListView></RelativeLayout>

add_delete:
<?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="match_parent"    android:orientation="horizontal">    <TextView        android:textSize="20dp"        android:id="@+id/delete"        android:text="-"        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <TextView        android:textSize="20dp"        android:id="@+id/count"        android:text=""        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <TextView        android:textSize="20dp"        android:id="@+id/add"        android:text="+"        android:layout_width="wrap_content"        android:layout_height="wrap_content" /></LinearLayout>
child_item:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent">    <CheckBox        android:id="@+id/main_check_all"        android:layout_width="30dp"        android:layout_height="30dp"        android:layout_below="@+id/textView4"        android:layout_alignParentLeft="true"        android:layout_alignParentStart="true" />    <ImageView        android:id="@+id/imageView3"        android:layout_width="90dp"        android:layout_height="90dp"        app:srcCompat="@mipmap/ic_launcher"        android:layout_alignParentTop="true"        android:layout_toRightOf="@+id/main_check_all"        android:layout_toEndOf="@+id/main_check_all" />    <TextView        android:id="@+id/textView4"        android:textSize="15dp"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="TextView"        android:layout_alignParentTop="true"        android:layout_toRightOf="@+id/imageView3"        android:layout_toEndOf="@+id/imageView3" />    <TextView        android:id="@+id/textView5"        android:textSize="10dp"        android:textColor="#c91622"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="TextView"        android:layout_below="@+id/main_check_all"        android:layout_toRightOf="@+id/imageView3"        android:layout_toEndOf="@+id/imageView3" />    <com.bwei.view.ShopAddDelete        android:id="@+id/ad"        android:layout_width="80dp"        android:layout_height="30dp"        android:layout_alignBottom="@+id/imageView3"        android:layout_alignParentRight="true"        android:layout_alignParentEnd="true" />    <Button        android:id="@+id/button"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentEnd="true"        android:layout_alignParentRight="true"        android:layout_alignParentTop="true"        android:text="删除"        android:visibility="gone"/></RelativeLayout>
group_item:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent">    <CheckBox        android:id="@+id/main_check_all"        android:layout_width="35dp"        android:layout_height="35dp"        android:layout_alignParentTop="true"        android:layout_alignParentLeft="true"        android:layout_alignParentStart="true" />    <TextView        android:id="@+id/textView3"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="11dp"        android:layout_marginStart="11dp"        android:text="TextView"        android:layout_alignBaseline="@+id/main_check_all"        android:layout_alignBottom="@+id/main_check_all"        android:layout_toRightOf="@+id/main_check_all"        android:layout_toEndOf="@+id/main_check_all" /></RelativeLayout>