1.分类左侧bean
package com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean; import java.util.List; /** * Created by dell on 2018/4/12. */ public class FenLeiDataBean_left { /** * msg : * code : 0 * data : [{"cid":1,"createtime":"2017-10-10T19:41:39","icon":"http://120.27.23.105/images/category/shop.png","ishome":1,"name":"京东超市"},{"cid":2,"createtime":"2017-10-10T19:41:39","icon":"http://120.27.23.105/images/category/qqg.png","ishome":1,"name":"全球购"},{"cid":3,"createtime":"2017-10-10T19:45:11","icon":"http://120.27.23.105/images/category/phone.png","ishome":1,"name":"手机数码"},{"cid":5,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/man.png","ishome":1,"name":"男装"},{"cid":6,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/girl.png","ishome":1,"name":"女装"},{"cid":7,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/manshoe.png","ishome":1,"name":"男鞋"},{"cid":8,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/girlshoe.png","ishome":1,"name":"女鞋"},{"cid":9,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/shirt.png","ishome":1,"name":"内衣配饰"},{"cid":10,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/bag.png","ishome":1,"name":"箱包手袋"},{"cid":11,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/beauty.png","ishome":1,"name":"美妆个护"},{"cid":12,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/jewel.png","ishome":1,"name":"钟表珠宝"},{"cid":13,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/luxury.png","ishome":1,"name":"奢侈品"},{"cid":14,"createtime":"2017-10-10T20:12:03","icon":"http://120.27.23.105/images/category/computer.png","ishome":1,"name":"电脑办公"},{"cid":15,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"家用电器"},{"cid":16,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"食品生鲜"},{"cid":17,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"酒水饮料"},{"cid":18,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"母婴童装"},{"cid":19,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"玩具乐器"},{"cid":20,"createtime":"2017-09-29T10:13:48","icon":"http://120.27.23.105/images/icon.png","ishome":0,"name":"医药保健"}] */ 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 { /** * cid : 1 * createtime : 2017-10-10T19:41:39 * icon : http://120.27.23.105/images/category/shop.png * ishome : 1 * name : 京东超市 */ private int cid; private String createtime; private String icon; private int ishome; private String name; public int getCid() { return cid; } public void setCid(int cid) { this.cid = cid; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public int getIshome() { return ishome; } public void setIshome(int ishome) { this.ishome = ishome; } public String getName() { return name; } public void setName(String name) { this.name = name; } } }
2.分类右侧Bena
package com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean; import java.util.List; /** * Created by dell on 2018/4/12. */ public class FenLeiDataBean_ringht { /** * msg : 获取子分类成功 * code : 0 * data : [{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"月饼","pcid":1,"pscid":1},{"icon":"http://120.27.23.105/images/icon.png","name":"坚果炒货","pcid":1,"pscid":2},{"icon":"http://120.27.23.105/images/icon.png","name":"糖巧","pcid":1,"pscid":3},{"icon":"http://120.27.23.105/images/icon.png","name":"休闲零食","pcid":1,"pscid":4},{"icon":"http://120.27.23.105/images/icon.png","name":"肉干肉脯","pcid":1,"pscid":5},{"icon":"http://120.27.23.105/images/icon.png","name":"饼干蛋糕","pcid":1,"pscid":6},{"icon":"http://120.27.23.105/images/icon.png","name":"蜜饯果干","pcid":1,"pscid":7},{"icon":"http://120.27.23.105/images/icon.png","name":"无糖食品","pcid":1,"pscid":8}],"name":"休闲零食","pcid":"1"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"新鲜水果","pcid":2,"pscid":9},{"icon":"http://120.27.23.105/images/icon.png","name":"海鲜水产","pcid":2,"pscid":10},{"icon":"http://120.27.23.105/images/icon.png","name":"精选肉类","pcid":2,"pscid":11},{"icon":"http://120.27.23.105/images/icon.png","name":"蛋类","pcid":2,"pscid":12},{"icon":"http://120.27.23.105/images/icon.png","name":"新鲜蔬菜","pcid":2,"pscid":13},{"icon":"http://120.27.23.105/images/icon.png","name":"冷冻食品","pcid":2,"pscid":14},{"icon":"http://120.27.23.105/images/icon.png","name":"饮品甜品","pcid":2,"pscid":15},{"icon":"http://120.27.23.105/images/icon.png","name":"大闸蟹","pcid":2,"pscid":16}],"name":"京东生鲜","pcid":"2"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"大米","pcid":3,"pscid":21},{"icon":"http://120.27.23.105/images/icon.png","name":"面粉","pcid":3,"pscid":22},{"icon":"http://120.27.23.105/images/icon.png","name":"杂粮","pcid":3,"pscid":23},{"icon":"http://120.27.23.105/images/icon.png","name":"食用油","pcid":3,"pscid":24},{"icon":"http://120.27.23.105/images/icon.png","name":"调味品","pcid":3,"pscid":25},{"icon":"http://120.27.23.105/images/icon.png","name":"方便速食","pcid":3,"pscid":26},{"icon":"http://120.27.23.105/images/icon.png","name":"有机食品","pcid":3,"pscid":27}],"name":"粮油调味","pcid":"3"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"饮用水","pcid":4,"pscid":28},{"icon":"http://120.27.23.105/images/icon.png","name":"饮料","pcid":4,"pscid":29},{"icon":"http://120.27.23.105/images/icon.png","name":"牛奶乳品","pcid":4,"pscid":30},{"icon":"http://120.27.23.105/images/icon.png","name":"名茶","pcid":4,"pscid":31},{"icon":"http://120.27.23.105/images/icon.png","name":"蜂蜜","pcid":4,"pscid":32}],"name":"水饮茗茶","pcid":"4"},{"cid":"1","list":[{"icon":"http://120.27.23.105/images/icon.png","name":"白酒","pcid":5,"pscid":33},{"icon":"http://120.27.23.105/images/icon.png","name":"葡萄酒","pcid":5,"pscid":34},{"icon":"http://120.27.23.105/images/icon.png","name":"洋酒","pcid":5,"pscid":35},{"icon":"http://120.27.23.105/images/icon.png","name":"啤酒","pcid":5,"pscid":36},{"icon":"http://120.27.23.105/images/icon.png","name":"黄酒","pcid":5,"pscid":37},{"icon":"http://120.27.23.105/images/icon.png","name":"陈年老酒","pcid":5,"pscid":38}],"name":"中外名酒","pcid":"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 { /** * cid : 1 * list : [{"icon":"http://120.27.23.105/images/icon.png","name":"月饼","pcid":1,"pscid":1},{"icon":"http://120.27.23.105/images/icon.png","name":"坚果炒货","pcid":1,"pscid":2},{"icon":"http://120.27.23.105/images/icon.png","name":"糖巧","pcid":1,"pscid":3},{"icon":"http://120.27.23.105/images/icon.png","name":"休闲零食","pcid":1,"pscid":4},{"icon":"http://120.27.23.105/images/icon.png","name":"肉干肉脯","pcid":1,"pscid":5},{"icon":"http://120.27.23.105/images/icon.png","name":"饼干蛋糕","pcid":1,"pscid":6},{"icon":"http://120.27.23.105/images/icon.png","name":"蜜饯果干","pcid":1,"pscid":7},{"icon":"http://120.27.23.105/images/icon.png","name":"无糖食品","pcid":1,"pscid":8}] * name : 休闲零食 * pcid : 1 */ private String cid; private String name; private String pcid; private List<ListBean> list; public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPcid() { return pcid; } public void setPcid(String pcid) { this.pcid = pcid; } public List<ListBean> getList() { return list; } public void setList(List<ListBean> list) { this.list = list; } public static class ListBean { /** * icon : http://120.27.23.105/images/icon.png * name : 月饼 * pcid : 1 * pscid : 1 */ private String icon; private String name; private int pcid; private int pscid; public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getPcid() { return pcid; } public void setPcid(int pcid) { this.pcid = pcid; } public int getPscid() { return pscid; } public void setPscid(int pscid) { this.pscid = pscid; } } } }
3.分类列表bean
package com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean; import java.util.List; /** * Created by dell on 2018/5/3. */ public class FenLeiLBDataBean { /** * msg : 请求成功 * code : 0 * data : [{"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","itemtype":1,"pid":20,"price":599,"pscid":1,"salenum":10000,"sellerid":13,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":0,"pid":8,"price":324,"pscid":1,"salenum":3000,"sellerid":1,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":2,"pid":9,"price":78.99,"pscid":1,"salenum":2356,"sellerid":2,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":2,"pid":22,"price":799,"pscid":1,"salenum":1300,"sellerid":15,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":0,"pid":21,"price":699,"pscid":1,"salenum":1299,"sellerid":14,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":1,"pid":7,"price":120.01,"pscid":1,"salenum":1266,"sellerid":23,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":0,"pid":3,"price":198,"pscid":1,"salenum":1234,"sellerid":19,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":1,"pid":19,"price":499,"pscid":1,"salenum":1111,"sellerid":12,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":1,"pid":2,"price":299,"pscid":1,"salenum":999,"sellerid":18,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"},{"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","itemtype":0,"pid":17,"price":299,"pscid":1,"salenum":888,"sellerid":10,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}] * page : 1 */ private String msg; private String code; private String page; 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 String getPage() { return page; } public void setPage(String page) { this.page = page; } public List<DataBean> getData() { return data; } public void setData(List<DataBean> data) { this.data = data; } public static class DataBean { /** * 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 * itemtype : 1 * pid : 20 * price : 599.0 * pscid : 1 * salenum : 10000 * sellerid : 13 * subhead : 每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下 * title : 北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g */ private double bargainPrice; private String createtime; private String detailUrl; private String images; private int itemtype; private int pid; private double price; private int pscid; private int salenum; 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 getItemtype() { return itemtype; } public void setItemtype(int itemtype) { this.itemtype = itemtype; } 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 getSalenum() { return salenum; } public void setSalenum(int salenum) { this.salenum = salenum; } 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; } } }
4.左侧M层
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataModel_left { //定义请求数据的方法 void getData(String url, FenLeiDataPrsenter fenLeIDataPrsenter); }
5.左侧M层实现
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter; import com.example.dell.jingdong201804.utils.RetrofitUtils; import io.reactivex.Flowable; /** * Created by dell on 2018/4/11. */ public class MyFenLeiDataModel_left implements FenLeiDataModel_left { //重写请求数据的方法 @Override public void getData(String url, final FenLeiDataPrsenter fenLeIDataPrsenter) { Flowable<FenLeiDataBean_left> fenLei = RetrofitUtils.getInstance(url).getApiService().getLeft(); fenLeIDataPrsenter.Success(fenLei); } }
6.右侧M层
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter_right; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataModel_right { //定义请求数据的方法 void getData2(String url,String cid,FenLeiDataPrsenter_right fenLeiDataPrsenter_right); }
7.右侧M层实现
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter_right; import com.example.dell.jingdong201804.utils.OkhtttpUtils; import com.example.dell.jingdong201804.utils.RetrofitUtils; import com.google.gson.Gson; import java.io.IOException; import java.util.List; import io.reactivex.Flowable; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Response; /** * Created by dell on 2018/4/11. */ public class MyFenLeiDataModel_right implements FenLeiDataModel_right { //重写请求数据的方法 @Override public void getData2(String url,String cid, final FenLeiDataPrsenter_right fenLeiDataPrsenter_right) { Flowable<FenLeiDataBean_ringht> right = RetrofitUtils.getInstance(url).getApiService().getRight(cid); fenLeiDataPrsenter_right.Success(right); } }
8.分类列表M层
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter_right; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiLBDataPrsenter; /** * Created by dell on 2018/4/11. */ public interface FenLeiLBDataModel { //定义请求数据的方法 void getFenLeiLBDataModel(String url, String pscid, FenLeiLBDataPrsenter prsenter); }
9.分类列表M层实现
package com.example.dell.jingdong201804.model.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiDataPrsenter_right; import com.example.dell.jingdong201804.presenter.FenLei.FenLeiLBDataPrsenter; import com.example.dell.jingdong201804.utils.RetrofitUtils; import io.reactivex.Flowable; /** * Created by dell on 2018/4/11. */ public class MyFenLeiLBDataModel implements FenLeiLBDataModel { //重写请求数据的方法 @Override public void getFenLeiLBDataModel(String url, String pscid, FenLeiLBDataPrsenter prsenter) { Flowable<FenLeiLBDataBean> fenLeiLB = RetrofitUtils.getInstance(url).getApiService().getFenLeiLB(pscid); prsenter.Success(fenLeiLB); } }
10.左侧P层
package com.example.dell.jingdong201804.presenter.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import java.util.List; import io.reactivex.Flowable; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataPrsenter { //定义成功与失败的方法 void Success(Flowable<FenLeiDataBean_left> fenLei); void Error(); }
11.左侧P层显示
package com.example.dell.jingdong201804.presenter.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import com.example.dell.jingdong201804.model.FenLei.MyFenLeiDataModel_left; import com.example.dell.jingdong201804.view.FenLei.FenLeiDataView; import java.util.List; import io.reactivex.Flowable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import io.reactivex.subscribers.DisposableSubscriber; /** * Created by dell on 2018/4/11. */ public class MyFenLeiDataPrsenter implements FenLeiDataPrsenter { //创建构造 FenLeiDataView fenLeiDataView; private final MyFenLeiDataModel_left myFenLeiDataModel; public MyFenLeiDataPrsenter(FenLeiDataView fenLeiDataView) { this.fenLeiDataView=fenLeiDataView; //实例化M层 myFenLeiDataModel = new MyFenLeiDataModel_left(); } //重写成功与失败的方法 @Override public void Success(Flowable<FenLeiDataBean_left> fenLei) { fenLei.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableSubscriber<FenLeiDataBean_left>() { @Override public void onNext(FenLeiDataBean_left fenLeiDataBean_left) { fenLeiDataView.toBackHome(fenLeiDataBean_left); } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); } // @Override // public void Success(List<FenLeiDataBean_left.DataBean> list) { // fenLeiDataView.toBackHome(list); // // } @Override public void Error() { } //调用接收url的方法 public void netWork(String url){ //进行请求 myFenLeiDataModel.getData(url,this); } }
12.右侧P层
package com.example.dell.jingdong201804.presenter.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import java.util.List; import io.reactivex.Flowable; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataPrsenter_right { //定义成功与失败的方法 void Success(Flowable<FenLeiDataBean_ringht> right ); void Error(); }
13.右侧P层实现
package com.example.dell.jingdong201804.presenter.FenLei; import android.util.Log; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.model.FenLei.MyFenLeiDataModel_right; import com.example.dell.jingdong201804.view.FenLei.FenLeiDataView_right; import java.util.List; import io.reactivex.Flowable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import io.reactivex.subscribers.DisposableSubscriber; /** * Created by dell on 2018/4/11. */ public class MyFenLeiDataPrsenter_right implements FenLeiDataPrsenter_right { //创建构造 FenLeiDataView_right fenLeiDataView_right; private final MyFenLeiDataModel_right myFenLeiDataModel_right; public MyFenLeiDataPrsenter_right(FenLeiDataView_right fenLeiDataView_right) { this.fenLeiDataView_right=fenLeiDataView_right; //实例化M层 myFenLeiDataModel_right = new MyFenLeiDataModel_right(); } //重写成功与失败的方法 @Override public void Success(Flowable<FenLeiDataBean_ringht> right) { right.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableSubscriber<FenLeiDataBean_ringht>() { @Override public void onNext(FenLeiDataBean_ringht fenLeiDataBean_ringht) { Log.e("右侧数据", "onNext: "+fenLeiDataBean_ringht.getMsg() ); fenLeiDataView_right.toBackHome2(fenLeiDataBean_ringht); } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); } @Override public void Error() { } //调用接收url的方法 public void netWork2(String url,String cid){ //进行请求 myFenLeiDataModel_right.getData2(url,cid,this); } }
14.列表p层
package com.example.dell.jingdong201804.presenter.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; import io.reactivex.Flowable; /** * Created by dell on 2018/4/11. */ public interface FenLeiLBDataPrsenter { //定义成功与失败的方法 void Success(Flowable<FenLeiLBDataBean> fenLeiLB); void Error(); }
15.列表P层实现
package com.example.dell.jingdong201804.presenter.FenLei; import android.util.Log; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; import com.example.dell.jingdong201804.model.FenLei.MyFenLeiDataModel_right; import com.example.dell.jingdong201804.model.FenLei.MyFenLeiLBDataModel; import com.example.dell.jingdong201804.view.FenLei.FenLeiDataView_right; import com.example.dell.jingdong201804.view.FenLei.FenLeiLBDataView; import io.reactivex.Flowable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; import io.reactivex.subscribers.DisposableSubscriber; /** * Created by dell on 2018/4/11. */ public class MyFenLeiLBDataPrsenter implements FenLeiLBDataPrsenter { FenLeiLBDataView dataView; private final MyFenLeiLBDataModel model; public MyFenLeiLBDataPrsenter(FenLeiLBDataView dataView){ this.dataView=dataView; model = new MyFenLeiLBDataModel(); } //重写成功与失败的方法 @Override public void Success(Flowable<FenLeiLBDataBean> fenLeiLB) { fenLeiLB.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableSubscriber<FenLeiLBDataBean>() { @Override public void onNext(FenLeiLBDataBean fenLeiLBDataBean) { Log.e("+++", "onNext: "+fenLeiLBDataBean.getMsg() ); dataView.toBackHome(fenLeiLBDataBean); } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); } @Override public void Error() { } //调用接收url的方法 public void getLb(String url,String pscid){ //进行请求 model.getFenLeiLBDataModel(url,pscid,this); } }
16.左侧V层
package com.example.dell.jingdong201804.view.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import java.util.List; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataView { //定义接收数据的方法 void toBackHome(FenLeiDataBean_left fenLeiDataBean_left); }
17.左侧V层实现
package com.example.dell.jingdong201804.view.FenLei; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.Toast; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.adapter.FenLei.FenLeiAdapter_left; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import com.example.dell.jingdong201804.presenter.FenLei.MyFenLeiDataPrsenter; import java.util.List; public class Fragment02 extends Fragment implements FenLeiDataView, FenLeiAdapter_left.OnClickListener { private RecyclerView fl_left_rcv; private FrameLayout fl_frame; private LinearLayout sao_lin; private LinearLayout xiao_lin; private List<FenLeiDataBean_left.DataBean> list; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_fragment02,container,false); //找到资源控件的ID fl_left_rcv = view.findViewById(R.id.fl_left_rcv); sao_lin = view.findViewById(R.id.sao_lin); xiao_lin = view.findViewById(R.id.xiao_lin); String url = "https://www.zhaoapi.cn/"; sao_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(getActivity(),"扫出了好吃的",Toast.LENGTH_SHORT).show(); } }); xiao_lin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(getActivity(),"恭喜得到水果一份",Toast.LENGTH_SHORT).show(); } }); //设置管理器 fl_left_rcv.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false)); //实例化P层 将M层传给p层 MyFenLeiDataPrsenter myFenLeiDataPrsenter = new MyFenLeiDataPrsenter(this); myFenLeiDataPrsenter.netWork(url); //将Cid传给右边的RecyclerView FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction(); Fragment_zi fragment_zi = new Fragment_zi(); fragment_zi.urlid(1); fragmentTransaction.replace(R.id.fl_frame,fragment_zi); fragmentTransaction.commit(); return view; } //重写接收数据的方法 @Override public void toBackHome(FenLeiDataBean_left fenLeiDataBean_left) { //接收数据 list = fenLeiDataBean_left.getData(); //创建适配器 FenLeiAdapter_left fenLeiAdapter = new FenLeiAdapter_left(getActivity(), list); fl_left_rcv.setAdapter(fenLeiAdapter); //调用条目点击方法 fenLeiAdapter.OnClick(Fragment02.this); } //条目点击事件 @Override public void OnItemClick(int position) { //得到分类的Cid int cid = list.get(position).getCid(); Log.e("条目:", "OnItemClick: "+cid ); //将Cid传给右边的RecyclerView FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction(); Fragment_zi fragment_zi = new Fragment_zi(); fragment_zi.urlid(cid); fragmentTransaction.replace(R.id.fl_frame,fragment_zi); fragmentTransaction.commit(); } }
18.右侧V层
package com.example.dell.jingdong201804.view.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import java.util.List; /** * Created by dell on 2018/4/11. */ public interface FenLeiDataView_right { //定义接收数据的方法 void toBackHome2(FenLeiDataBean_ringht fenLeiDataBean_ringht); }
19.右侧V层实现
package com.example.dell.jingdong201804.view.FenLei; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.adapter.FenLei.FenLeiAdapter_right; import com.example.dell.jingdong201804.adapter.FenLei.FenLeiAdapter_ringht2; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.presenter.FenLei.MyFenLeiDataPrsenter_right; import com.facebook.drawee.view.SimpleDraweeView; import java.util.ArrayList; import java.util.List; public class Fragment_zi extends Fragment implements FenLeiDataView_right{ private RecyclerView right_rcv; List<List<FenLeiDataBean_ringht.DataBean.ListBean>> list2 = new ArrayList<>(); private SimpleDraweeView right_img; private int i; private List<FenLeiDataBean_ringht.DataBean> beanList; private FenLeiAdapter_right fenLeiAdapter_right; String url="https://www.zhaoapi.cn/"; String Urlcid= ""; private MyFenLeiDataPrsenter_right myFenLeiDataPrsenter_right; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_fragment_right, container, false); //找到资源控件的ID right_rcv = view.findViewById(R.id.right_rcv); right_img = view.findViewById(R.id.right_img); //创建管理器 right_rcv.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false)); myFenLeiDataPrsenter_right = new MyFenLeiDataPrsenter_right(this); myFenLeiDataPrsenter_right.netWork2(url,Urlcid); //切换图片 if(i==1){ right_img.setImageURI("http://cdn.xiangyouhui.cn/uploads/201604/weipinhui160411li02.jpg0d98b9cc-ab6e-2f4a-a7f8-5c6eaf71c449.jpg"); }else if(i==2){ right_img.setImageURI("http://cdn.xiangyouhui.cn/uploads/201604/weipinhui160407li01.jpg198f9dd9-7d28-eb95-dd6f-626c08879e85.jpg"); }else if(i==3) { right_img.setImageURI("http://c3.haibao.cn/img/600_0_100_1/1459134080.1117/a4302dd16cf8e8a080534e313672547a.jpg"); }else if(i==5) { right_img.setImageURI("http://cdn.xiangyouhui.cn/uploads/201704/weipinhui170412li01.jpg610712bc-789a-b8a8-d3a7-492103001fb4.jpg"); } else if(i==6) { right_img.setImageURI("http://c3.haibao.cn/img/600_0_100_1/1459134080.1117/a4302dd16cf8e8a080534e313672547a.jpg"); }else { right_img.setImageURI("http://cdn.xiangyouhui.cn/uploads/201611/jingdong20161105zheng01.jpgc9c20d24-d25d-562f-c758-6a7aba6ddc5e.jpg"); } return view; } //接收传来的cid public void urlid(int cid){ Log.e("++++传来的id", "urlid: "+cid ); Urlcid+=cid; Log.e("++++传来的Urlcid", "urlid: "+Urlcid); //用于判断下标 切换图片 i = cid; } @Override public void toBackHome2(FenLeiDataBean_ringht fenLeiDataBean_ringht) { //得到一级数据 beanList = fenLeiDataBean_ringht.getData(); //得到二级数据 for (int i = 0; i< beanList.size(); i++){ list2.add(beanList.get(i).getList()); } //创建适配器 fenLeiAdapter_right = new FenLeiAdapter_right(getActivity(), beanList, list2); right_rcv.setAdapter(fenLeiAdapter_right); } }
20.列表V层
package com.example.dell.jingdong201804.view.FenLei; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; /** * Created by dell on 2018/4/11. */ public interface FenLeiLBDataView { //定义接收数据的方法 void toBackHome(FenLeiLBDataBean fenLeiLBDataBean); }
21.列表V层实现
package com.example.dell.jingdong201804.view.FenLei; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.widget.TextView; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.adapter.FenLei.FenLeiLBAdapter; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; import com.example.dell.jingdong201804.presenter.FenLei.MyFenLeiLBDataPrsenter; import com.example.dell.jingdong201804.view.ShouYe.ShouYeXQActivity; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; public class FenLeiLBActivity extends AppCompatActivity implements FenLeiLBDataView, FenLeiLBAdapter.OnClickListener { @BindView(R.id.fl_lb_rcv) RecyclerView fl_Lb_Rcv; @BindView(R.id.fl_lb_fh) TextView fl_Lb_Fh; private List<FenLeiLBDataBean.DataBean> list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fen_lei_lb); ButterKnife.bind(this); String url = "https://www.zhaoapi.cn/"; //获取点击的条目ID Intent intent = getIntent(); int pscid1 = intent.getIntExtra("pscid", 0); String pscid = String.valueOf(pscid1); Log.e("++++接收:", "onCreate: " + pscid); //实例化P层 调用P层方法 MyFenLeiLBDataPrsenter prsenter = new MyFenLeiLBDataPrsenter(this); prsenter.getLb(url, pscid); } //接收数据 @Override public void toBackHome(FenLeiLBDataBean fenLeiLBDataBean) { list = fenLeiLBDataBean.getData(); Log.e("分类列表的数据:", "toBackHome: " + list.size()); //设置布局管理器 fl_Lb_Rcv.setLayoutManager(new LinearLayoutManager(this)); //创建适配器 FenLeiLBAdapter fenLeiLBAdapter = new FenLeiLBAdapter(this, list); fl_Lb_Rcv.setAdapter(fenLeiLBAdapter); //调用点击事件 fenLeiLBAdapter.setOnclick(this); } //条目点击事件 @Override public void OnItemClick(int position) { // Toast.makeText(this,"点击了"+position,Toast.LENGTH_SHORT).show(); //得到Pid int pid = list.get(position).getPid(); //携带pid跳转到详情页面 Intent intent = new Intent(FenLeiLBActivity.this, ShouYeXQActivity.class); intent.putExtra("pid", String.valueOf(pid)); startActivity(intent); } @OnClick(R.id.fl_lb_fh) public void onViewClicked() { finish(); } }
22.主布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:background="#F3F5F7" android:orientation="vertical" tools:context="com.example.dell.jingdong201804.view.FenLei.Fragment02"> <LinearLayout android:layout_width="match_parent" android:layout_height="60px" android:background="#fff"> <include layout="@layout/title_layout"></include> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <android.support.v7.widget.RecyclerView android:id="@+id/fl_left_rcv" android:layout_width="100px" android:layout_height="match_parent" android:background="#FFFFFF"> </android.support.v7.widget.RecyclerView> <FrameLayout android:id="@+id/fl_frame" android:layout_marginLeft="10px" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF"> </FrameLayout> </LinearLayout> </LinearLayout>
23.左侧布局
<?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="wrap_content" android:orientation="vertical" android:layout_gravity="center" android:gravity="center"> <TextView android:id="@+id/fl_left_name" android:layout_width="match_parent" android:layout_height="80px" android:text="京东超市" android:padding="10px" android:layout_gravity="center" android:gravity="center"/> </LinearLayout>
24右侧布局
<?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="wrap_content" android:orientation="vertical" android:background="#F3F5F7" android:padding="10px"> <TextView android:id="@+id/fl_right_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10px" android:textStyle="bold" android:text="休闲零食"/> <android.support.v7.widget.RecyclerView android:id="@+id/fl_ringht_rcv2" android:layout_width="match_parent" android:layout_height="wrap_content"> </android.support.v7.widget.RecyclerView> </LinearLayout>
25.右侧布局2
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10px"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/fl_ringht_img" android:layout_width="80px" android:layout_height="80px" android:src="@mipmap/ic_launcher"/> <TextView android:id="@+id/fl_right_name2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10px" android:layout_gravity="center" android:text="京东超市"/> </LinearLayout> </RelativeLayout>
26.列表布局
<?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="wrap_content" android:orientation="vertical" android:padding="10px"> <LinearLayout android:layout_width="match_parent" android:layout_height="100dp" android:orientation="horizontal"> <ImageView android:id="@+id/fl_lb_rcv_img" android:layout_width="100dp" android:layout_height="100dp" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_below="@+id/fl_lb_rcv_title" android:src="@mipmap/ic_launcher" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp"> <TextView android:id="@+id/fl_lb_rcv_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"/> <TextView android:id="@+id/fl_lb_rcv_price" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#f00" android:layout_below="@id/fl_lb_rcv_title" android:layout_alignParentBottom="true" android:gravity="bottom" android:text="¥599.0"/> </RelativeLayout> </LinearLayout> </LinearLayout>
27.右侧布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context="com.example.dell.jingdong201804.view.FenLei.Fragment_zi"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/right_img" android:layout_width="match_parent" android:layout_height="200px"/> <android.support.v7.widget.RecyclerView android:id="@+id/right_rcv" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v7.widget.RecyclerView> </LinearLayout>
27.左侧适配器
package com.example.dell.jingdong201804.adapter.FenLei; import android.content.Context; import android.graphics.Color; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_left; import java.util.List; /** * Created by dell on 2018/4/12. */ public class FenLeiAdapter_left extends RecyclerView.Adapter{ int index=0; Context context; List<FenLeiDataBean_left.DataBean> list; public FenLeiAdapter_left(Context context, List<FenLeiDataBean_left.DataBean> list) { this.context=context; this.list=list; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { //引入条目布局 View view = LayoutInflater.from(context).inflate(R.layout.fl_left_rcv_item,parent,false); //创建ViewHolder,将view传过去 MyViewHolder myViewHolder = new MyViewHolder(view); return myViewHolder; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { final MyViewHolder myViewHolder = (MyViewHolder) holder; myViewHolder.fl_left_name.setText(list.get(position).getName()); //进行条目点击事件 myViewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onClickListener.OnItemClick(position); index=position; notifyDataSetChanged(); } }); if(index==position){ myViewHolder.fl_left_name.setBackgroundColor(Color.parseColor("#C0C0C0")); myViewHolder.fl_left_name.setTextColor(Color.parseColor("#FF0000")); }else{ myViewHolder.fl_left_name.setBackgroundColor(Color.parseColor("#ffffff")); myViewHolder.fl_left_name.setTextColor(Color.parseColor("#000000")); } } //条目数量 @Override public int getItemCount() { return list.size(); } class MyViewHolder extends RecyclerView.ViewHolder{ private final TextView fl_left_name; public MyViewHolder(View view) { super(view); //找到条目布局中的控件ID fl_left_name = view.findViewById(R.id.fl_left_name); } } //创建方法 OnClickListener onClickListener; public void OnClick(OnClickListener onClickListener){ this.onClickListener=onClickListener; } //创建接口 public interface OnClickListener{ void OnItemClick(int position); } }
28.右侧适配器1
package com.example.dell.jingdong201804.adapter.FenLei; import android.content.Context; import android.content.Intent; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import com.example.dell.jingdong201804.view.FenLei.FenLeiLBActivity; import java.util.List; /** * Created by dell on 2018/4/12. */ public class FenLeiAdapter_right extends RecyclerView.Adapter implements FenLeiAdapter_ringht2.OnClickListener { Context context; List<FenLeiDataBean_ringht.DataBean> list_right; List<List<FenLeiDataBean_ringht.DataBean.ListBean>> list2; public FenLeiAdapter_right(Context context, List<FenLeiDataBean_ringht.DataBean> list_right, List<List<FenLeiDataBean_ringht.DataBean.ListBean>> list2) { this.context=context; this.list_right=list_right; this.list2=list2; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { //引入条目布局 View view = LayoutInflater.from(context).inflate(R.layout.fl_right_rcv_item,parent, false); //创建ViewHolder,将view传过去 MyViewHolder2 myViewHolder2 = new MyViewHolder2(view); return myViewHolder2; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { MyViewHolder2 myViewHolder2 = (MyViewHolder2) holder; //进行赋值 myViewHolder2.fl_right_name.setText(list_right.get(position).getName()); //设置管理器 myViewHolder2.fl_ringht_rcv2.setLayoutManager(new GridLayoutManager(context,3)); //进入第二个适配器 FenLeiAdapter_ringht2 fenLeiAdapter_ringht2 = new FenLeiAdapter_ringht2(context,list2.get(position)); myViewHolder2.fl_ringht_rcv2.setAdapter(fenLeiAdapter_ringht2); //调用适配器中的点击事件 fenLeiAdapter_ringht2.OnClick(this); } @Override public int getItemCount() { return list_right.size(); } //点击事件 @Override public void OnItemClick(List<FenLeiDataBean_ringht.DataBean.ListBean> list2, int position) { //获取pscid int pscid = list2.get(position).getPscid(); Toast.makeText(context,"点击了"+pscid,Toast.LENGTH_SHORT).show(); //携带值跳转到分类的列表页面 Intent intent = new Intent(context,FenLeiLBActivity.class); intent.putExtra("pscid",pscid); context.startActivity(intent); } class MyViewHolder2 extends RecyclerView.ViewHolder{ private final TextView fl_right_name; private final RecyclerView fl_ringht_rcv2; public MyViewHolder2(View view) { super(view); //找到条目布局中的控件ID fl_right_name = view.findViewById(R.id.fl_right_name); fl_ringht_rcv2 = view.findViewById(R.id.fl_ringht_rcv2); } } }
29.右侧适配器2
package com.example.dell.jingdong201804.adapter.FenLei; 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.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiDataBean_ringht; import java.util.List; public class FenLeiAdapter_ringht2 extends RecyclerView.Adapter{ Context context; List<FenLeiDataBean_ringht.DataBean.ListBean> list2; public FenLeiAdapter_ringht2(Context context, List<FenLeiDataBean_ringht.DataBean.ListBean> list2) { this.context=context; this.list2=list2; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.fl_right_rcv_item2, parent,false); MyViewHolder3 myViewHolder3 = new MyViewHolder3(view); return myViewHolder3; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { MyViewHolder3 myViewHolder3 = (MyViewHolder3) holder; myViewHolder3.fl_right_name2.setText(list2.get(position).getName()); Glide.with(context).load(list2.get(position).getIcon()).into(myViewHolder3.fl_ringht_img); //进行条目点击事件 myViewHolder3.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onClickListener.OnItemClick(list2,position); } }); } @Override public int getItemCount() { return list2.size(); } class MyViewHolder3 extends RecyclerView.ViewHolder{ private final ImageView fl_ringht_img; private final TextView fl_right_name2; public MyViewHolder3(View view) { super(view); fl_ringht_img = view.findViewById(R.id.fl_ringht_img); fl_right_name2 = view.findViewById(R.id.fl_right_name2); } } //创建方法 OnClickListener onClickListener; public void OnClick(OnClickListener onClickListener){ this.onClickListener=onClickListener; } //创建接口 public interface OnClickListener{ //参数需传入:当前集合 和下标 void OnItemClick(List<FenLeiDataBean_ringht.DataBean.ListBean> list2, int position); } }
30.列表适配器
package com.example.dell.jingdong201804.adapter.FenLei; 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.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import com.example.dell.jingdong201804.R; import com.example.dell.jingdong201804.model.FenLei.FenLeiDataBean.FenLeiLBDataBean; import java.util.List; /** * Created by dell on 2018/5/3. */ public class FenLeiLBAdapter extends RecyclerView.Adapter { Context context; List<FenLeiLBDataBean.DataBean> list; public FenLeiLBAdapter(Context context, List<FenLeiLBDataBean.DataBean> list) { this.context = context; this.list = list; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(context).inflate(R.layout.fl_lb_rcv_item, parent, false); //创建ViewHolder,将view传过去 MyViewHolder myViewHolder = new MyViewHolder(view); return myViewHolder; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { MyViewHolder myViewHolder = (MyViewHolder) holder; String[] split = list.get(position).getImages().split("\\|"); Glide.with(context).load(split[0]).into(myViewHolder.fl_lb_rcv_img); myViewHolder.fl_lb_rcv_title.setText(list.get(position).getTitle()); myViewHolder.fl_lb_rcv_price.setText("¥"+list.get(position).getPrice()); //设置条目的点击事件 myViewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onClickListener.OnItemClick(position); } }); } @Override public int getItemCount() { return list.size(); } class MyViewHolder extends RecyclerView.ViewHolder { private final ImageView fl_lb_rcv_img; private final TextView fl_lb_rcv_title; private final TextView fl_lb_rcv_price; public MyViewHolder(View view) { super(view); //找到条目布局中的控件ID fl_lb_rcv_img = view.findViewById(R.id.fl_lb_rcv_img); fl_lb_rcv_title = view.findViewById(R.id.fl_lb_rcv_title); fl_lb_rcv_price = view.findViewById(R.id.fl_lb_rcv_price); } } //定义方法 OnClickListener onClickListener; public void setOnclick(OnClickListener onClickListener){ this.onClickListener=onClickListener; } //定义接口 public interface OnClickListener{ void OnItemClick(int position); } }