仿淘宝购物车

来源:互联网 发布:数据库去掉重复行 编辑:程序博客网 时间:2024/03/28 22:35


首先这篇博客主要就是实现一个仿京东购物车的类型,我用的MVP模式,主要实现的功能就是,全选,反选和删除,多的不说了,直接开粘吧。

Retrofit的接口

public interface Inters {        @GET("product/getCarts")    Observable<AddBean> gets(@Query("uid") int uid);}

Bean包

public class AddBean{    /**     * 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":2,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":1,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"},{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":2,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","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":106,"pid":10,"price":555.55,"pscid":1,"selected":0,"sellerid":3,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"bargainPrice":5599,"createtime":"2017-10-10T17:30:32","detailUrl":"https://item.m.jd.com/product/4824715.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n12/jfs/t7768/184/1153704394/148460/f42e1432/599a930fN8a85626b.jpg!q70.jpg","num":1,"pid":59,"price":5599,"pscid":40,"selected":0,"sellerid":3,"subhead":"游戏本选择4G独显,拒绝掉帧】升级版IPS全高清防眩光显示屏,WASD方向键颜色加持,三大出风口立体散热!","title":"戴尔DELL灵越游匣15PR-6648B GTX1050 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 128GSSD+1T 4G独显 IPS)黑"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","num":2,"pid":48,"price":222,"pscid":39,"selected":0,"sellerid":4,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":61,"price":14999,"pscid":40,"selected":0,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","num":1,"pid":50,"price":444,"pscid":39,"selected":0,"sellerid":6,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家6","sellerid":"6"},{"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":2,"pid":100,"price":2200,"pscid":112,"selected":0,"sellerid":11,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"}],"sellerName":"商家11","sellerid":"11"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":69,"price":16999,"pscid":40,"selected":0,"sellerid":13,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家13","sellerid":"13"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家15","sellerid":"15"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:38:26","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":23,"price":188,"pscid":1,"selected":0,"sellerid":16,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家16","sellerid":"16"}]     */    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":2,"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 : 2             * 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;            // 1 显示商家  2 隐藏商家            private int isFirst;            // true 表示商家选中 false 相反            private boolean shopSelected;            // true 表示 当前商品是选中的 false 相反            private boolean itemSelected;            public ListBean(int isFirst, boolean shopSelected, boolean itemSelected) {                this.isFirst = isFirst;                this.shopSelected = shopSelected;                this.itemSelected = itemSelected;            }            public int getIsFirst() {                return isFirst;            }            public void setIsFirst(int isFirst) {                this.isFirst = isFirst;            }            public boolean isShopSelected() {                return shopSelected;            }            public void setShopSelected(boolean shopSelected) {                this.shopSelected = shopSelected;            }            public boolean isItemSelected() {                return itemSelected;            }            public void setItemSelected(boolean itemSelected) {                this.itemSelected = 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;            }        }    }}

Retrofit+Rxjava+OkHttp的结合框架请求的,

public class RetrofitUnitl {    private Retrofit mRetrofit;    private String baseUrl;    OkHttpClient client;    private static RetrofitUnitl mRetrofitManager;    private RetrofitUnitl(String baseUrl,OkHttpClient client){        this.baseUrl=baseUrl;        this.client=client;        initRetrofit();    }    public static synchronized RetrofitUnitl getInstance(String baseUrl,OkHttpClient client){        if (mRetrofitManager == null){            mRetrofitManager = new RetrofitUnitl(baseUrl,client);        }        return mRetrofitManager;    }    private void initRetrofit() {        mRetrofit = new Retrofit.Builder()                .baseUrl(baseUrl)                .addConverterFactory(GsonConverterFactory.create())                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())                .client(client)                .build();    }    public <T> T setCreate(Class<T> reqServer) {        return mRetrofit.create(reqServer);    }}

下面直接开始MVP

V层

public interface IGouView {    void onsuccer(AddBean bean);//成功的方法}
M层

public class GouModel {    ScuMod scuMod;    public void setScuMod(ScuMod scuMod) {        this.scuMod = scuMod;    }        //自己定义一个请求方法    public void Succes(){        OkHttpClient ok = new OkHttpClient.Builder()                .build();        //请求数据        RetrofitUnitl.getInstance("http://120.27.23.105/",ok)                .setCreate(Inters.class)                .gets(98)                .observeOn(AndroidSchedulers.mainThread())                .subscribeOn(Schedulers.io())                .subscribe(new Subscriber<AddBean>() {                    @Override                    public void onCompleted() {                    }                    @Override                    public void onError(Throwable e) {                    }                    @Override                    public void onNext(AddBean bean) {                        scuMod.MScus(bean);                        Log.e("===========",bean.getData().get(0).getSellerName());;                    }                });    }    //定义一个接口    public interface ScuMod{        void MScus(AddBean bean);    }}
P层,我用的弱引用解绑,防止内存泄漏,可以不写。

public class GouPresenter implements GouModel.ScuMod {    //弱引用解绑    WeakReference<IGouView> view;    GouModel model;    public GouPresenter( IGouView view) {        attach(view);        model = new GouModel();        model.setScuMod(this);    }    @Override    public void MScus(AddBean bean) {        view.get().onsuccer(bean);    }    //我们在写一个方法拿到我们的请求    public void  ShowPer(){        model.Succes();    }    //绑定    public void attach(IGouView views){        view = new WeakReference(views);    }    //解绑方法    public void detach(){        view.clear();    }}
自定义一个plusview

public class plusview extends LinearLayout {    Button revserse,tianjian;    EditText edittext;    private  int mcount = 1;//定义一个常量 用于购物车就入时默认显示为1    public plusview(Context context) {        super(context);    }    public  plusview(Context context, AttributeSet attributeSet){        super(context,attributeSet);        //首先加载布局文件        View view = View.inflate(context, R.layout.plus_layout,null);        //初始化控件        revserse = view.findViewById(R.id.revserse);//减号        tianjian = view.findViewById(R.id.tianjian);//加好        edittext = view.findViewById(R.id.edittext);//加号减号中间的输入框        //控件初始化玩之后 控件设置点击事件        revserse.setOnClickListener(new OnClickListener() {            //减号的点击事件            @Override            public void onClick(View view) {                String trims = edittext.getText().toString().trim();//获取输入框的值去掉空格                int coun = Integer.valueOf(trims);//把从输入框的得到的值转换成整形                if (coun>1){                    mcount = coun-1;                    edittext.setText(mcount+"");                    if (listener!=null){                        listener.click(mcount);                    }                }            }        });        //加号的点击事件        tianjian.setOnClickListener(new OnClickListener() {            @Override            public void onClick(View view) {                String trim = edittext.getText().toString().trim();//获取输入框的值去掉空格                int coun = Integer.valueOf(trim)+1;//把从输入框的得到的值转换成整形                mcount = coun;                edittext.setText(coun+"");                if (listener!=null){                    listener.click(coun);                }            }        });        //输入框的点击事件        edittext.addTextChangedListener(new TextWatcher() {            @Override            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {            }            @Override            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {            }            @Override            public void afterTextChanged(Editable editable) {            }        });        addView(view);  //添加布局    }    public plusview(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {        super(context, attrs, defStyleAttr);    }    public void setEditText(int num){        if(edittext != null){            edittext.setText(num+"");        }    }    public ClickListener listener;    public void setListener(ClickListener listener ){        this.listener=listener;    }    /**     * 加减号的点击事件     */    public  interface  ClickListener{        public void click(int coun);    }}

自定义中的布局

<?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">    <Button        android:id="@+id/revserse"        android:layout_width="20dp"        android:layout_height="20dp"        android:background="#FF00"        android:text="-"        />    <EditText        android:id="@+id/edittext"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:inputType="number"        android:text="1" />    <Button        android:id="@+id/tianjian"        android:layout_width="20dp"        android:layout_height="20dp"        android:background="#FF00"        android:text="+" /></LinearLayout>

适配器

public class ShopAdapter extends RecyclerView.Adapter<ShopAdapter.ViewHolder>{    private Context context;//传入上下文    private List<AddBean.DataBean.ListBean> list;//bean包的集合    //存放商家的集合    private Map<String, String> map = new HashMap<>();    //有参构造    public ShopAdapter(Context context) {        this.context = context;    }    /**     * 添加数据并更新     */    public void add(AddBean bean) {        //判段如果list是空的        if (this.list == null) {            //那就把listNew出来            this.list = new ArrayList<>();        }        //遍历商家        for (AddBean.DataBean shop : bean.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 这里把集合给setFirst这个方法就是要设置商品的显示与阴藏     */    private void setFirst(List<AddBean.DataBean.ListBean> list) {        //这里判断  如果集合的字符大于0 你就默认显示一个商家        if (list.size() > 0) {            list.get(0).setIsFirst(1);   //这是默认显示商家            for (int i = 1; i < list.size(); i++) {  //这是For循环把集合里的所有元素循出来                if (list.get(i).getSellerid() == list.get(i - 1).getSellerid()) {                    //如果俩个商品是同一个商家的那么就让这两个商品只显示一个商家                    list.get(i).setIsFirst(2);                } else {                    //如果不是 就两个都显示                    list.get(i).setIsFirst(1);                    if (list.get(i).isItemSelected()) {                        list.get(i).setShopSelected(list.get(i).isItemSelected());                    }                }            }        }    }    /**     * 加载布局文件     */    @Override    public ShopAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view = View.inflate(context, R.layout.adapter_layout, null);        //添加到ViewHolder里        return new ViewHolder(view);    }    @Override    public void onBindViewHolder(final ShopAdapter.ViewHolder holder, final int position) {        // 显示商品图片        if (list.get(position).getIsFirst() == 1) {            //显示商家  VISIBLE显示商品            holder.shop_checkbox.setVisibility(View.VISIBLE);//显示商家            holder.tv_item_shopcart_shopname.setVisibility(View.VISIBLE);//显示商家            holder.shop_checkbox.setChecked(list.get(position).isShopSelected());//            显示商家的名称//            list.get(position).getSellerid() 取到商家的id//            map.get()取到 商家的名称            holder.tv_item_shopcart_shopname.setText(map.get(String.valueOf(list.get(position).getSellerid())));        } else {            holder.shop_checkbox.setVisibility(View.GONE);//隐藏商家            holder.tv_item_shopcart_shopname.setVisibility(View.GONE);//隐藏商家        }        //控制 商品的  checkbox        holder.item_checkbox.setChecked(list.get(position).isItemSelected());        //这是分割  由于接口中的图片是连这的所以必须要分割        String[] url = list.get(position).getImages().split("\\|");        // 从分割完之后返回的数组中设置所要显示的图片        // ImageLoader.getInstance().displayImage(url[0], holder.item_pic);        Uri uri = Uri.parse(url[0]);        DraweeController controller = Fresco.newDraweeControllerBuilder()                .setUri(uri)                .setAutoPlayAnimations(true)                .build();        holder.item_pic.setController(controller);        //设置所要显示的文字 也是商家        holder.item_name.setText(list.get(position).getTitle());        //设置所要显示的价格        holder.item_price.setText(list.get(position).getPrice() + "");        //计算完所友的商品总价后在这设置显示        holder.plus_view_id.setEditText(list.get(position).getNum());        // 商家的checkbox  多选框        holder.shop_checkbox.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                list.get(position).setShopSelected(holder.shop_checkbox.isChecked());                for (int i = 0; i < list.size(); i++) {                    if (list.get(position).getSellerid() == list.get(i).getSellerid()) {                        list.get(i).setItemSelected(holder.shop_checkbox.isChecked());                    }                }                notifyDataSetChanged();//更新数据源                sum(list);//计算总价            }        });        // 商品的checkbox  多选框        holder.item_checkbox.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                list.get(position).setItemSelected(holder.item_checkbox.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.item_del.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                //从集合中移除商家信息                list.remove(position);                setFirst(list);                notifyDataSetChanged();//更新数据                sum(list);//算总价            }        });        //加减号        holder.plus_view_id.setListener(new plusview.ClickListener() {            @Override            public void click(int count) {                list.get(position).setNum(count);                notifyDataSetChanged();//更新适配器                sum(list);//计算总价            }        });    }    @Override    public int getItemCount() {        return list == null ? 0 : list.size();//三元运算符    }    /**     * 计算总价     *     * @param list     */    private void sum(List<AddBean.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 cl) {        for (int i = 0; i < list.size(); i++) {            list.get(i).setShopSelected(cl);            list.get(i).setItemSelected(cl);        }        notifyDataSetChanged();        sum(list);    }    public class ViewHolder extends RecyclerView.ViewHolder {        View view; //item_del;        plusview plus_view_id;        CheckBox shop_checkbox, item_checkbox;        TextView tv_item_shopcart_shopname, item_price, item_name, tv_item_shopcart_cloth_size;        SimpleDraweeView item_pic;        Button item_del;        public ViewHolder(View itemView) {            super(itemView);            view = itemView.findViewById(R.id.view);            item_del = itemView.findViewById(R.id.item_del);            shop_checkbox = itemView.findViewById(R.id.shop_checkbox);            item_checkbox = itemView.findViewById(R.id.item_checkbox);            tv_item_shopcart_shopname = itemView.findViewById(R.id.tv_item_shopcart_shopname);            item_price = itemView.findViewById(R.id.item_price);            item_name = itemView.findViewById(R.id.item_name);            tv_item_shopcart_cloth_size = itemView.findViewById(R.id.tv_item_shopcart_cloth_size);            item_pic = itemView.findViewById(R.id.item_pic);            plus_view_id = itemView.findViewById(R.id.plus_view_id);        }    }    public UpdateUiListener listener;    public void setListener(UpdateUiListener listener) {        this.listener = listener;    }    //更新接口数据    public interface UpdateUiListener {        public void setTotal(String total, String num, boolean allCheck);    }}
适配器布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="match_parent">    <LinearLayout        android:id="@+id/ll_shopcart_header"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:orientation="vertical">        <View            android:id="@+id/view"            android:layout_width="match_parent"            android:layout_height="@dimen/margin_10dp"            android:background="@color/background_color" />        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:gravity="center_vertical">            <!-- 商店checkbox -->            <CheckBox                android:id="@+id/shop_checkbox"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:paddingBottom="@dimen/margin_10dp"                android:paddingLeft="@dimen/margin_15dp"                android:paddingRight="@dimen/margin_15dp"                android:paddingTop="@dimen/margin_10dp"                />            <!-- 商店名称 -->            <TextView                android:id="@+id/tv_item_shopcart_shopname"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:drawablePadding="@dimen/padding_5dp"                android:padding="@dimen/padding_10dp"                android:text="宝儿家服装"                android:textColor="@color/cblack" />        </LinearLayout>    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:gravity="center_vertical">        <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" />            <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:gravity="center_vertical"                android:orientation="horizontal">                <!-- 商品 checkbox -->                <CheckBox                    android:id="@+id/item_checkbox"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:padding="@dimen/margin_15dp"                    />                <!-- 商品图片 -->                <com.facebook.drawee.view.SimpleDraweeView                    android:id="@+id/item_pic"                    android:layout_width="60dp"                    android:layout_height="60dp"                    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:id="@+id/item_price"                        android:layout_width="wrap_content"                        android:layout_height="wrap_content"                        android:text="¥185"                        android:textColor="@color/main_red_text"                        android:textSize="@dimen/common_font_size_14" />                    <LinearLayout                        android:layout_width="wrap_content"                        android:layout_height="wrap_content"                        android:layout_marginBottom="@dimen/margin_5dp"                        android:layout_marginTop="@dimen/margin_5dp">                        <TextView                            android:id="@+id/item_name"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:text="颜色:黑色"                            android:textColor="@color/cblack"                            android:textSize="@dimen/common_font_size_12" />                        <TextView                            android:id="@+id/tv_item_shopcart_cloth_size"                            android:layout_width="wrap_content"                            android:layout_height="wrap_content"                            android:layout_marginLeft="@dimen/margin_10dp"                            android:text="尺寸:XL"                            android:textColor="@color/cblack"                            android:textSize="@dimen/common_font_size_12" />                    </LinearLayout>                    <xinjiaqi.bwie.com.xinjiaqi20171211.zdy.plusview                        android:id="@+id/plus_view_id"                        android:layout_width="100dp"                        android:layout_height="wrap_content">                    </xinjiaqi.bwie.com.xinjiaqi20171211.zdy.plusview>                </LinearLayout>                <View                    android:layout_width="@dimen/margin_1dp"                    android:layout_height="match_parent"                    android:layout_marginBottom="@dimen/padding_10dp"                    android:layout_marginTop="@dimen/padding_10dp"                    android:background="@color/splitline_color" />                <Button                    android:id="@+id/item_del"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:padding="@dimen/margin_20dp"                    android:text="删除"                    android:background="#f0f0f0"                    />            </LinearLayout>        </LinearLayout>    </LinearLayout>    <View        android:layout_width="match_parent"        android:layout_height="@dimen/margin_1dp"        android:background="@color/background_color" /></LinearLayout>

主方法

public class MainActivity extends AppCompatActivity implements IGouView {    RecyclerView third_recyclerview;    LinearLayout third_pay_linear;    CheckBox third_allselect;    Button third_submit;    TextView edittext, third_totalnum, third_totalprice;    private GouPresenter presenter;    private ShopAdapter adapter;    AddBean shopBean;    List<AddBean> list  = new ArrayList<>();    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        //找控控件        third_recyclerview = (RecyclerView) findViewById(R.id.third_recyclerview);        third_pay_linear = (LinearLayout) findViewById(R.id.third_pay_linear);        third_allselect = (CheckBox) findViewById(R.id.third_allselect);        third_totalprice = (TextView) findViewById(R.id.third_totalprice);        edittext = (TextView) findViewById(R.id.edittext);        third_totalnum = (TextView) findViewById(R.id.third_totalnum);        third_submit = (Button) findViewById(R.id.third_submit);        //调用P层        presenter = new GouPresenter(this);        presenter.ShowPer();        //线性布局       LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);        third_recyclerview.setLayoutManager(manager);         //绑定适配器        adapter = new ShopAdapter(MainActivity.this);        third_recyclerview.setAdapter(adapter);        third_allselect.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View view) {                adapter.selectAll(third_allselect.isChecked());            }        });        adapter.setListener(new ShopAdapter.UpdateUiListener() {            @Override            public void setTotal(String total, String num, boolean allCheck) {                third_allselect.setChecked(allCheck);                third_totalnum.setText(num);                third_totalprice.setText(total);            }        });    }    @Override    public void onsuccer(AddBean bean) {        adapter.add(bean);    }   //解绑    @Override    protected void onDestroy() {        super.onDestroy();        presenter.detach();    }}

主方法布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="match_parent">    <android.support.v7.widget.RecyclerView        android:id="@+id/third_recyclerview"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1" />    <LinearLayout        android:id="@+id/third_pay_linear"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="0"        android:background="#FFFFFF"        android:gravity="center_vertical"        android:orientation="horizontal">        <CheckBox            android:id="@+id/third_allselect"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="@dimen/margin_10dp"            android:checked="false"            android:drawablePadding="@dimen/padding_5dp"            android:text="全选" />        <LinearLayout            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight="1"            android:orientation="vertical">            <TextView                android:id="@+id/third_totalprice"                android:layout_width="200dp"                android:layout_height="wrap_content"                android:paddingLeft="@dimen/padding_10dp"                android:paddingTop="@dimen/padding_10dp"                android:text="总价:"                android:textColor="@color/cblack"                android:textSize="@dimen/common_font_size_16" />            <TextView                android:id="@+id/third_totalnum"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:paddingBottom="@dimen/padding_10dp"                android:paddingLeft="@dimen/padding_10dp"                android:text="共0件商品"                android:textColor="@color/cblack"                android:textSize="@dimen/common_font_size_14" />        </LinearLayout>        <Button            android:id="@+id/third_submit"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginRight="@dimen/margin_10dp"            android:paddingBottom="@dimen/padding_10dp"            android:paddingLeft="@dimen/margin_30dp"            android:paddingRight="@dimen/margin_30dp"            android:paddingTop="@dimen/padding_10dp"            android:text="去结算"            android:textColor="#000000" />    </LinearLayout></LinearLayout>

最后我们需要配置values下面的文件

colors.xml

<?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>
diment.xml

<?xml version="1.0" encoding="utf-8"?><resources>    <!-- Default screen margins, per the Android Design guidelines. -->    <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>
还有在drawable下面创建三个view

view.xml

<?xml version="1.0" encoding="utf-8"?><vector xmlns:android="http://schemas.android.com/apk/res/android"    android:width="108dp"    android:height="108dp"    android:viewportHeight="108"    android:viewportWidth="108"    >    <path        android:fillColor="#26A69A"        android:pathData="M0,0h108v108h-108z" />    <path        android:fillColor="#00000000"        android:pathData="M9,0L9,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,0L19,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M29,0L29,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M39,0L39,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M49,0L49,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M59,0L59,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M69,0L69,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M79,0L79,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M89,0L89,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M99,0L99,108"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,9L108,9"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,19L108,19"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,29L108,29"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,39L108,39"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,49L108,49"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,59L108,59"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,69L108,69"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,79L108,79"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,89L108,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M0,99L108,99"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,29L89,29"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,39L89,39"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,49L89,49"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,59L89,59"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,69L89,69"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M19,79L89,79"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M29,19L29,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M39,19L39,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M49,19L49,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M59,19L59,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M69,19L69,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" />    <path        android:fillColor="#00000000"        android:pathData="M79,19L79,89"        android:strokeColor="#33FFFFFF"        android:strokeWidth="0.8" /></vector>
view1.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>
view2.xml

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

Bean包要手动添加这三个定义的

         // 1 显示商家  2 隐藏商家            private int isFirst;            // true 表示商家选中 false 相反            private boolean shopSelected;            // true 表示 当前商品是选中的 false 相反            private boolean itemSelected;

代码完事以后,记得在清单文件中加入权限

<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
依赖就不导了




原创粉丝点击