二级购物车


配置

compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile files('libs/gson-2.2.4.jar')
compile 'com.android.support:recyclerview-v7:26.+'
compile files('libs/universal-image-loader-1.9.5.jar')

//清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.kk">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:name=".view.MyApp"
        android:allowBackup="true" android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true" android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 
 
DataDataBean
package com.example.kk.bean;

import java.util.List;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public class DataDataBean {
    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":1,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg","num":1,"pid":91,"price":1344,"pscid":112,"selected":0,"sellerid":2,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"},{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":1,"pid":9,"price":78.99,"pscid":1,"selected":0,"sellerid":2,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":1,"pid":34,"price":9,"pscid":2,"selected":0,"sellerid":11,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家11","sellerid":"11"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":1,"pid":6,"price":7.99,"pscid":1,"selected":0,"sellerid":22,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家22","sellerid":"22"}]
     */

    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":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg","num":1,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}]
         * sellerName : 商家1
         * sellerid : 1
         */

        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 : 22.9
             * createtime : 2017-10-14T21:48:08
             * detailUrl : https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
             * images : https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.jpg
             * num : 1
             * pid : 24
             * price : 288.0
             * pscid : 2
             * selected : 0
             * sellerid : 1
             * subhead : 三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》
             * title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋
             */

            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 int isFirst;
            private boolean shopSelected;
            private boolean itemSelected;

            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;
            }

            public void setIsFirst(int isFirst) {
                this.isFirst = isFirst;
            }

            public int getIsFirst() {
                return isFirst;
            }

            public boolean isShopSelected() {
                return shopSelected;
            }

            public boolean isItemSelected() {
                return itemSelected;
            }

            public void setShopSelected(boolean shopSelected) {
                this.shopSelected = shopSelected;
            }

            public void setItemSelected(boolean itemSelected) {
                this.itemSelected = itemSelected;
            }
        }
    }
}
Model
package com.example.kk.Model;

import android.util.Log;

import com.example.kk.bean.DataDataBean;
import com.example.kk.okhttpp.AbstractUiCallBack;
import com.example.kk.okhttpp.OkhttpUtils;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public class MyModel {
    public void  getData(final MyModelCallBack callBack){
        OkhttpUtils.getInstance().asy(null, "http://120.27.23.105/product/getCarts?uid=170", new AbstractUiCallBack<DataDataBean>() {
            @Override
            public void success(DataDataBean dataDataBean) {
                Log.e("=====",dataDataBean.toString());
                callBack.success(dataDataBean);

            }

            @Override
            public void failure(Exception e) {
                callBack.fail(e);

            }
        });
    }
}
MyModelCallBack

package com.example.kk.Model;

import com.example.kk.bean.DataDataBean;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public interface MyModelCallBack {
    void success(DataDataBean dataDataBean);

    void fail(Exception e);
}
MyPresenter
package com.example.kk.presenter;

import com.example.kk.Model.MyModel;
import com.example.kk.Model.MyModelCallBack;
import com.example.kk.MyViewListener;
import com.example.kk.bean.DataDataBean;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public class MyPresenter {
    private MyModel model;
    private MyViewListener listener;
    public  MyPresenter(MyViewListener listener){
        this.listener=listener;
        model=new MyModel();
    }



    public void getData(){
        model.getData(new MyModelCallBack() {
            @Override
            public void success(DataDataBean dataDataBean) {
                if(listener!=null){
                    listener.success(dataDataBean);
                }

            }

            @Override
            public void fail(Exception e) {
                if(listener!=null){
                    listener.fail(e);
                }

            }
        });
    }
    //防止内存泄漏
    public  void detach(){
        listener=null;
    }
}

//view层

MainActivity
package com.example.kk;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;

import com.example.kk.bean.DataDataBean;
import com.example.kk.presenter.MyPresenter;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity implements  MyViewListener {
    @Bind(R.id.recyclerview)
    RecyclerView recyclerview;
    @Bind(R.id.quanxuan)
    CheckBox quanxuan;
    @Bind(R.id.count_zong)
    TextView countZong;
    @Bind(R.id.price_zong)
    TextView priceZong;
    private MyPresenter presenter;
    private ShopAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        presenter = new MyPresenter(this);
        presenter.getData();

        adapter = new ShopAdapter(this);
        LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerview.setLayoutManager(manager);
        recyclerview.setAdapter(adapter);
        adapter.setListener(new ShopAdapter.UpdateUiListener() {
            @Override
            public void setTotal(String total, String num, boolean allCheck) {
                quanxuan.setChecked(allCheck);
                countZong.setText(num);
                priceZong.setText(total);

            }
        });
    }
    @Override
    public void success(DataDataBean dataDataBean) {
        adapter.add(dataDataBean);
    }

    @Override
    public void fail(Exception e) {
        Toast.makeText(this, "error", Toast.LENGTH_SHORT).show();


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.detach();
    }
    @OnClick(R.id.quanxuan)
    public void onViewClicked() {

        adapter.selectAll(quanxuan.isChecked());


    }
}
MyViewListener
package com.example.kk;

import com.example.kk.bean.DataDataBean;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public interface MyViewListener {
    void success(DataDataBean dataDataBean);

    void fail(Exception e);
}
ShopAdapter

package com.example.kk;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.kk.bean.DataDataBean;
import com.example.kk.view.PlasView;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * author:Created by WangZhiQiang on 2017/12/20.
 */

public class ShopAdapter  extends RecyclerView.Adapter<ShopAdapter.IViewHolder>  {
    Context context;

    private List<DataDataBean.DataBean.ListBean> list;
    private Map<String, String> map = new HashMap<>();
    private List<DataDataBean.DataBean.ListBean> first;

    public ShopAdapter(Context context) {
        this.context = context;
    }


    /**
     * 添加数据 并更新显示
     *
     * @param dataDataBean
     */
    public void add(DataDataBean dataDataBean) {
        if (this.list == null) {
            this.list = new ArrayList<>();
        }
        //遍历商家
        for (DataDataBean.DataBean shop : dataDataBean.getData()) {
            map.put(shop.getSellerid(), shop.getSellerName());
            //遍历商品
            for (int i = 0; i < shop.getList().size(); i++) {
                this.list.add(shop.getList().get(i));
            }
        }
        setFirst(this.list);
        notifyDataSetChanged();
    }
    /**
     * 设置数据源, 控制显示商家
     * @param list
     */
    public void setFirst(List<DataDataBean.DataBean.ListBean> list) {
        if(list.size()>0){
            list.get(0).setIsFirst(1);
            for (int i=1;i<list.size();i++){
                if(list.get(i).getSellerid()==list.get(i-1).getSellerid()){
                    list.get(i).setIsFirst(2);
                }else{
                    list.get(i).setIsFirst(1);
                }
            }
        }

    }



    @Override
    public IViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.adapter_layout, null);

        return new IViewHolder(view);
    }




    @Override
    public void onBindViewHolder(final IViewHolder holder, final int position) {
        //显示商品图片
        if(list.get(position).getIsFirst()==1){
            //显示商家
            holder.shopCheckbox.setVisibility(View.VISIBLE);
            holder.shopname.setVisibility(View.VISIBLE);
            holder.shopCheckbox.setChecked(list.get(position).isShopSelected());

//            显示商家的名称
//            list.get(position).getSellerid() 取到商家的id
//            map.get()取到 商家的名称
            holder.shopname.setText(map.get(String.valueOf(list.get(position).getSellerid())));
        }else{
            holder.shopCheckbox.setVisibility(View.GONE);
            holder.shopname.setVisibility(View.GONE);
        }
        //控制 商品的  checkbox
        holder.itemCheckbox.setChecked(list.get(position).isItemSelected());
        String[] url = list.get(position).getImages().split("\\|");
        ImageLoader.getInstance().displayImage(url[0],holder.itemPic);
        holder.itemName.setText(list.get(position).getTitle());
        holder.itemPrice.setText("¥"+list.get(position).getPrice()+"");
        holder.plusViewId.setEditText(list.get(position).getNum());




        // 商家的checkbox
        holder.shopCheckbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                list.get(position).setShopSelected(holder.shopCheckbox.isChecked());

                for(int i=0;i<list.size();i++){
                    if(list.get(position).getSellerid() == list.get(i).getSellerid()){
                        list.get(i).setItemSelected(holder.shopCheckbox.isChecked());
                    }
                }

                notifyDataSetChanged();
                sum(list);

            }
        });
        // 商品的checkbox
        holder.itemCheckbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                list.get(position).setItemSelected(holder.itemCheckbox.isChecked());


                for(int i=0;i<list.size();i++){
                    for (int j=0;j<list.size();j++){
                        if(list.get(i).getSellerid() == list.get(j).getSellerid() && !list.get(j).isItemSelected()){
                            list.get(i).setShopSelected(false);
                            break;
                        }else {
                            list.get(i).setShopSelected(true);
                        }
                    }
                }

                notifyDataSetChanged();
                sum(list);

            }
        });

//删除
        holder.itemDel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                list.remove(position);
                setFirst(list);
                notifyDataSetChanged();
                sum(list);
            }
        });



        //加减号
        holder.plusViewId.setListener(new PlasView.ClickListener() {
            @Override
            public void click(int count) {
                list.get(position).setNum(count);
                notifyDataSetChanged();
                sum(list);

            }
        });


    }



    /**
     * 计算总价
     * @param list
     */
    private void  sum(List<DataDataBean.DataBean.ListBean> list){
        int totalNum = 0 ;
        float totalMoney =  0.0f;

        boolean allCheck =true;
        for(int i=0;i<list.size();i++){
            if(list.get(i).isItemSelected()){
                totalNum += list.get(i).getNum() ;
                totalMoney += list.get(i).getNum() * list.get(i).getPrice();
            }else {
                allCheck = false;
            }
        }

        listener.setTotal(totalMoney+"",totalNum+"",allCheck);
    }

    //全选
    public  void selectAll(boolean check){
        for (int i=0;i<list.size();i++){
            list.get(i).setShopSelected(check);
            list.get(i).setItemSelected(check);
        }
        notifyDataSetChanged();
        sum(list);

    }


    @Override
    public int getItemCount() {
        return list==null ? 0 :list.size();
    }



    public class IViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.view)
        View view;
        @Bind(R.id.shop_checkbox)
        CheckBox shopCheckbox;
        @Bind(R.id.shopname)
        TextView shopname;
        @Bind(R.id.hander)
        LinearLayout hander;
        @Bind(R.id.item_checkbox)
        CheckBox itemCheckbox;
        @Bind(R.id.item_pic)
        ImageView itemPic;
        @Bind(R.id.item_price)
        TextView itemPrice;
        @Bind(R.id.item_name)
        TextView itemName;

        @Bind(R.id.plus_view_id)
        PlasView plusViewId;
        @Bind(R.id.item_del)
        ImageView itemDel;
        public IViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
    public UpdateUiListener listener;
    public void setListener(UpdateUiListener listener){
        this.listener = listener;
    }
    public interface UpdateUiListener {
        public void setTotal(String total,String num,boolean allCheck);
    }
}
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:orientation="vertical"
    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.example.kk.MainActivity">
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recyclerview"></android.support.v7.widget.RecyclerView>
    <LinearLayout
        android:gravity="center"
        android:background="#dedede"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal">
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/quanxuan"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="全选"/>
        <LinearLayout
            android:layout_marginRight="130dp"
            android:layout_marginLeft="50dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="共0件商品"
                android:id="@+id/count_zong"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="合计:¥0.00"
                android:id="@+id/price_zong"/>
        </LinearLayout>
        <Button
            android:textColor="#ffffff"
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:text="去结算(0)"
            android:background="#ff0000"
            />
    </LinearLayout>

</RelativeLayout>
//adapter_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/hander"
        android:orientation="vertical">
        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_10dp"
            android:background="@color/background_color"
            android:id="@+id/view"></View>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical">
            <!-- 商店checkbox-->
            <CheckBox
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/margin_15dp"
                android:paddingRight="@dimen/margin_15dp"
                android:paddingTop="@dimen/margin_10dp"
                android:paddingBottom="@dimen/margin_10dp"
                android:id="@+id/shop_checkbox"
                />
            <!--商店名称-->
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/shopname"
                android:textColor="@color/cblack"
                android:drawableLeft="@drawable/ic_normal_class_press"
                android:text="宝儿家服装"
                android:padding="@dimen/padding_10dp"
                android:drawablePadding="@dimen/padding_5dp"
                />
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/margin_1dp"
                android:background="@color/background_color"></View>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical">
                <!--商品checkbox-->
                <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/item_checkbox"
                    android:padding="@dimen/margin_15dp"/>
                <!--商品图片-->
                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:id="@+id/item_pic"
                    android:layout_margin="@dimen/margin_10dp"/>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/item_price"
                        android:text="¥185"
                        android:textColor="@color/main_red_text"
                        android:textSize="@dimen/common_font_size_14"/>
                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_5dp"
                        android:layout_marginBottom="@dimen/margin_5dp">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="颜色:黑色"
                            android:textSize="@dimen/common_font_size_12"
                            android:id="@+id/item_name"
                            android:textColor="@color/cblack"/>
                        <!-- <TextView
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:text="尺寸:XL"
                             android:textSize="@dimen/common_font_size_12"
                             android:textColor="@color/cblack"
                             android:id="@+id/item_size"
                             android:layout_marginLeft="@dimen/margin_10dp"/>-->
                        <com.example.kk.view.PlasView
                            android:layout_width="100dp"
                            android:layout_height="wrap_content"
                            android:id="@+id/plus_view_id"></com.example.kk.view.PlasView>
                    </LinearLayout>


                </LinearLayout>
                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:layout_marginTop="@dimen/padding_10dp"
                    android:layout_marginBottom="@dimen/padding_10dp"
                    android:background="@color/splitline_color">

                </View>
                <ImageView
                    android:id="@+id/item_del"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/margin_20dp"
                    android:src="@drawable/ic_normal_class"/>

            </LinearLayout>
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_1dp"
            android:background="@color/background_color"></View>
    </LinearLayout>
</LinearLayout>
//plus_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:layout_height="match_parent">
    <Button
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:id="@+id/revserse"
        android:text="-"
        android:background="#00FFFFFF"/>
    <EditText
        android:inputType="number"
        android:text="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/content"/>
    <Button
        android:background="#00FFFFFF"
        android:text="+"
        android:id="@+id/add"
        android:layout_width="30dp"
        android:layout_height="30dp"
        />
</LinearLayout>
//在drawable下面复制
login_btn.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <corners android:radius="@dimen/height_200dp"></corners>
    <solid android:color="@color/pressed_icon_color"></solid>
</shape>

shopcart_add.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <corners android:radius="@dimen/height_200dp"></corners>
    <stroke android:color="@color/background_color" android:width="1dp"></stroke>
</shape>
color
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>

    <color name="cwhite">#FFFFFF</color>

    <color name="title_bg">#FDE23D</color>

    <color name="tab_bg">#FFFFFF</color>

    <color name="tab_normal_textcolor">#373737</color>
    <color name="tab_selected_textcolor">#FDE23D</color>

    <color name="coffer">#442509</color>

    <color name="pressed_icon_color">#e53e42</color>

    <color name="background_color">#f6f6f6</color>

    <color name="main_red_text">#e53e42</color>
    <dimen name="padding_20dp">20dp</dimen>

    <color name="splitline_color">#dddddd</color>

    <color name="cblack">#000000</color>

</resources>
新建dimen
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="margin_10dp">10dp</dimen>
    <dimen name="padding_5dp">5dp</dimen>
    <dimen name="padding_10dp">10dp</dimen>


    <dimen name="common_font_size_16">16sp</dimen>
    <dimen name="common_font_size_14">14sp</dimen>


    <dimen name="height_200dp">200dp</dimen>

    <dimen name="margin_30dp">30dp</dimen>
    <dimen name="margin_15dp">15dp</dimen>
    <dimen name="margin_1dp">1dp</dimen>
    <dimen name="margin_5dp">5dp</dimen>
    <dimen name="common_font_size_12">12sp</dimen>

    <dimen name="padding_2dp">2dp</dimen>
    <dimen name="margin_20dp">20dp</dimen>
</resources>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值