Activity
public class MainActivity extends AppCompatActivity implements DataCall{
// String url = "http://www.zhaoapi.cn/product/getCarts?uid=71";
String getUrl = "{\n" +
"msg: \"请求成功\",\n" +
"code: \"0\",\n" +
"data: [\n" +
"{\n" +
"list: [ ],\n" +
"sellerName: \"\",\n" +
"sellerid: \"0\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-14T21:48:08\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 11,\n" +
"pid: 11,\n" +
"price: 8989,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 4,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家4\",\n" +
"sellerid: \"4\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-03T23:43:53\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 1,\n" +
"pid: 13,\n" +
"price: 465,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 6,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家6\",\n" +
"sellerid: \"6\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 11800,\n" +
"createtime: \"2017-10-14T21:38:26\",\n" +
"detailUrl: \"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1\",\n" +
"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\",\n" +
"num: 3,\n" +
"pid: 63,\n" +
"price: 10000,\n" +
"pscid: 40,\n" +
"selected: 0,\n" +
"sellerid: 7,\n" +
"subhead: \"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)\",\n" +
"title: \"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家7\",\n" +
"sellerid: \"7\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 399,\n" +
"createtime: \"2017-10-03T23:53:28\",\n" +
"detailUrl: \"https://item.m.jd.com/product/1439822107.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"images: \"https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24Ne854e14c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg\",\n" +
"num: 1,\n" +
"pid: 87,\n" +
"price: 888,\n" +
"pscid: 85,\n" +
"selected: 0,\n" +
"sellerid: 8,\n" +
"subhead: \"满2件,总价打6.50折\",\n" +
"title: \"Gap男装 休闲舒适简约水洗五袋直筒长裤紧身牛仔裤941825 深灰色 33/32(175/84A)\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 3455,\n" +
"createtime: \"2017-10-03T23:53:28\",\n" +
"detailUrl: \"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 2,\n" +
"pid: 52,\n" +
"price: 666,\n" +
"pscid: 39,\n" +
"selected: 0,\n" +
"sellerid: 8,\n" +
"subhead: \"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机\",\n" +
"title: \"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家8\",\n" +
"sellerid: \"8\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 11800,\n" +
"createtime: \"2017-10-14T21:48:08\",\n" +
"detailUrl: \"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1\",\n" +
"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\",\n" +
"num: 3,\n" +
"pid: 65,\n" +
"price: 12000,\n" +
"pscid: 40,\n" +
"selected: 0,\n" +
"sellerid: 9,\n" +
"subhead: \"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)\",\n" +
"title: \"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 2999,\n" +
"createtime: \"2017-10-14T21:48:08\",\n" +
"detailUrl: \"https://item.m.jd.com/product/2385655.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends\",\n" +
"images: \"https://m.360buyimg.com/n0/jfs/t2068/298/2448145915/157953/7be197df/56d51a42Nd86f1c8e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2437/128/1687178395/117431/bcc190c1/56d3fcbaNb2963d21.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2467/222/2263160610/95597/927b8a2f/56d3eafeNdecebeb6.jpg!q70.jpg\",\n" +
"num: 2,\n" +
"pid: 53,\n" +
"price: 777,\n" +
"pscid: 39,\n" +
"selected: 0,\n" +
"sellerid: 9,\n" +
"subhead: \"Super AMOLED三星双曲面2K 屏,支持无线充电!\",\n" +
"title: \"三星 Galaxy S7 edge(G9350)4GB+32GB 铂光金 移动联通电信4G手机 双卡双待\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-14T21:39:05\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 1,\n" +
"pid: 16,\n" +
"price: 199,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 9,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家9\",\n" +
"sellerid: \"9\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 11800,\n" +
"createtime: \"2017-10-14T21:38:26\",\n" +
"detailUrl: \"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1\",\n" +
"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\",\n" +
"num: 3,\n" +
"pid: 66,\n" +
"price: 13000,\n" +
"pscid: 40,\n" +
"selected: 0,\n" +
"sellerid: 10,\n" +
"subhead: \"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)\",\n" +
"title: \"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 159,\n" +
"createtime: \"2017-10-14T21:49:15\",\n" +
"detailUrl: \"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 5,\n" +
"pid: 99,\n" +
"price: 2100,\n" +
"pscid: 112,\n" +
"selected: 0,\n" +
"sellerid: 10,\n" +
"subhead: \"针织针织闪闪闪亮你的眼\",\n" +
"title: \"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-03T23:53:28\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 2,\n" +
"pid: 17,\n" +
"price: 299,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 10,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家10\",\n" +
"sellerid: \"10\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 159,\n" +
"createtime: \"2017-10-14T21:49:15\",\n" +
"detailUrl: \"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 1,\n" +
"pid: 100,\n" +
"price: 2200,\n" +
"pscid: 112,\n" +
"selected: 0,\n" +
"sellerid: 11,\n" +
"subhead: \"针织针织闪闪闪亮你的眼\",\n" +
"title: \"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 22.9,\n" +
"createtime: \"2017-10-14T21:38:26\",\n" +
"detailUrl: \"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 5,\n" +
"pid: 34,\n" +
"price: 9,\n" +
"pscid: 2,\n" +
"selected: 0,\n" +
"sellerid: 11,\n" +
"subhead: \"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》\",\n" +
"title: \"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋\"\n" +
"},\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-14T21:48:08\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 2,\n" +
"pid: 18,\n" +
"price: 399,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 11,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家11\",\n" +
"sellerid: \"11\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-14T21:39:05\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 3,\n" +
"pid: 19,\n" +
"price: 499,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 12,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家12\",\n" +
"sellerid: \"12\"\n" +
"},\n" +
"{\n" +
"list: [\n" +
"{\n" +
"bargainPrice: 111.99,\n" +
"createtime: \"2017-10-14T21:39:05\",\n" +
"detailUrl: \"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends\",\n" +
"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\",\n" +
"num: 3,\n" +
"pid: 1,\n" +
"price: 118,\n" +
"pscid: 1,\n" +
"selected: 0,\n" +
"sellerid: 17,\n" +
"subhead: \"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下\",\n" +
"title: \"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g\"\n" +
"}\n" +
"],\n" +
"sellerName: \"商家17\",\n" +
"sellerid: \"17\"\n" +
"}\n" +
"]\n" +
"}";
private ListView listView01;
private ListView listView02;
private List<Meau.DataBean> list = new ArrayList<>();
private List<Meau.DataBean.ListBean> list1 = new ArrayList<>();
private MyListViewYiAdapter adapter;
private MyListViewErAdapter adapter1;
private List<Meau.DataBean.ListBean> beans;
private List<Meau.DataBean> data;
private TextView zongjia;
private Meau.DataBean.ListBean listBean;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView01 = findViewById(R.id.listview01);
listView02 = findViewById(R.id.listview02);
zongjia = findViewById(R.id.zongjia);
RequestPresenter requestPresenter = new RequestPresenter(this);
requestPresenter.getRequest(getUrl);
adapter = new MyListViewYiAdapter(list, this);
adapter1 = new MyListViewErAdapter(list1, this);
//点击商铺切换商品
listView01.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this, "点击了" + position, Toast.LENGTH_LONG).show();
List<Meau.DataBean.ListBean> beans1 = data.get(position).getList();
list1.clear();
adapter1.notifyDataSetChanged();
list1.addAll(beans1);
adapter.notifyDataSetChanged();
adapter1.notifyDataSetChanged();
}
});
adapter1.setOnNumListener(new MyListViewErAdapter.OnNumListener() {
@Override
public void onNum(double asd) {
zongjia.setText(asd+"");
}
});
listView01.setAdapter(adapter);
listView02.setAdapter(adapter1);
}
@Override
public void requestSuccess(Meau meau) {
double totalPrice = 0;
for (int i = 0; i < list.size(); i++) {
totalPrice = totalPrice + beans.get(i).getPrice()*beans.get(i).getNum();
}
zongjia.setText(totalPrice+"");
data = meau.getData();
Log.i("abc", data.toString());
list.addAll(data);
beans = data.get(1).getList();
list1.addAll(beans);
adapter.notifyDataSetChanged();
adapter1.notifyDataSetChanged();
Toast.makeText(this, "成功" + meau.getData(), Toast.LENGTH_LONG).show();
}
@Override
public void requestFail(Meau meau) {
Toast.makeText(this, "失败", Toast.LENGTH_LONG).show();
}
Adapter
public class MyListViewYiAdapter extends BaseAdapter {
private List<Meau.DataBean> list = new ArrayList<>();
private Context context;
public MyListViewYiAdapter(List<Meau.DataBean> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null){
convertView = View.inflate(context, R.layout.listview_yi_layout, null);
holder = new ViewHolder();
holder.text_name = convertView.findViewById(R.id.text_name);
convertView.setTag(holder);
}else {
holder = (ViewHolder) convertView.getTag();
}
holder.text_name.setText(list.get(position).getSellerName());
return convertView;
}
class ViewHolder{
TextView text_name;
}
public class MyListViewErAdapter extends BaseAdapter {
private List<Meau.DataBean.ListBean> list = new ArrayList<>();
private Context context;
public MyListViewErAdapter(List<Meau.DataBean.ListBean> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
MyListViewErAdapter.ViewHolder holder;
if (convertView == null){
convertView = View.inflate(context, R.layout.listview_er_layout, null);
holder = new MyListViewErAdapter.ViewHolder();
holder.text_name = convertView.findViewById(R.id.text_name);
holder.text_price = convertView.findViewById(R.id.text_price);
holder.img_pic = convertView.findViewById(R.id.img_pic);
holder.myView = convertView.findViewById(R.id.myView);
convertView.setTag(holder);
}else {
holder = (MyListViewErAdapter.ViewHolder) convertView.getTag();
}
holder.text_name.setText(list.get(position).getTitle());
holder.text_price.setText(list.get(position).getPrice()+"");
String images = list.get(position).getImages();
String[] split = images.split("\\|");
if (split.length > 0) {
Glide.with(context).load(split[0]).into(holder.img_pic);
}
Log.i("asdf",list.get(position).getTitle());
holder.myView.setCount(list.get(position).getNum());
holder.myView.setMyViewListener(new MyView.MyViewListener() {
@Override
public void myView(int count) {
list.get(position).setNum(count);
Log.i("qwer--------------",count+"");
// onNumListener.onNum();
double totalPrice = 0;
for (int i = 0; i < list.size(); i++) {
Meau.DataBean.ListBean listBean = list.get(i);
totalPrice = totalPrice + listBean.getPrice() * listBean.getNum();
onNumListener.onNum(totalPrice);
}
}
});
return convertView;
}
class ViewHolder{
TextView text_name,text_price;
ImageView img_pic;
MyView myView;
}
private OnNumListener onNumListener;
public void setOnNumListener(OnNumListener onNumListener) {
this.onNumListener = onNumListener;
}
public interface OnNumListener{
void onNum(double asd);
}
bean
package com.bwie.myelm.bean;
import java.util.List;
public class Meau {
private int code;
private String msg;
private List<DataBean> data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public class DataBean {
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 class ListBean {
private double bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private int num;
private int pid;
private double price;
private int pscid;
private int selected;
private int sellerid;
private String subhead;
private String title;
public double getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(double bargainPrice) {
this.bargainPrice = bargainPrice;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getDetailUrl() {
return detailUrl;
}
public void setDetailUrl(String detailUrl) {
this.detailUrl = detailUrl;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getPscid() {
return pscid;
}
public void setPscid(int pscid) {
this.pscid = pscid;
}
public int getSelected() {
return selected;
}
public void setSelected(int selected) {
this.selected = selected;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int sellerid) {
this.sellerid = sellerid;
}
public String getSubhead() {
return subhead;
}
public void setSubhead(String subhead) {
this.subhead = subhead;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}
}
datacall
public interface DataCall {
void requestSuccess(Meau meau);
void requestFail(Meau meau);
}
MyView
public class MyView extends LinearLayout implements View.OnClickListener {
private TextView mAddBtn,mSubBtn;
private TextView mNumText;
private MyViewListener myViewListener;
public MyView(Context context) {
super(context);
initView();
}
public MyView(Context context,AttributeSet attrs) {
super(context, attrs);
initView();
}
public MyView(Context context,AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView();
}
private void initView(){
//加载layout布局,第三个参数ViewGroup一定写成this
View view = View.inflate(getContext(),R.layout.car_add_sub_layout,this);
mAddBtn = view.findViewById(R.id.btn_add);
mSubBtn = view.findViewById(R.id.btn_sub);
mNumText = view.findViewById(R.id.text_number);
mAddBtn.setOnClickListener(this);
mSubBtn.setOnClickListener(this);
}
// @Override
// protected void onLayout(boolean changed, int l, int t, int r, int b) {
// super.onLayout(changed, l, t, r, b);
//
// int width = r-l;//getWidth();
// int height = b-t;//getHeight();
//
// }
@Override
public void onClick(View v) {
int number = Integer.parseInt(mNumText.getText().toString());
switch (v.getId()){
case R.id.btn_add:
number++;
mNumText.setText(number+"");
break;
case R.id.btn_sub:
if (number==0){
Toast.makeText(getContext(),"数量不能小于0",Toast.LENGTH_LONG).show();
return;
}
number--;
mNumText.setText(number+"");
break;
}
if (myViewListener != null){
myViewListener.myView(number);
}
}
public void setCount(int count){
mNumText.setText(count+"");
}
public void setMyViewListener(MyViewListener myViewListener) {
this.myViewListener = myViewListener;
}
public interface MyViewListener{
void myView(int count);
}
Utils
public class Utils {
public static String get(String url){
OkHttpClient okHttpClient = new OkHttpClient();
Request build = new Request.Builder().url(url).get().build();
try {
Response execute = okHttpClient.newCall(build).execute();
return execute.body().string();
} catch (IOException e) {
e.printStackTrace();
}
return “”;
}
}
model
public class RequestModel {
public static Meau getData(String url){
// String s = Utils.get(url);
Gson gson = new Gson();
Meau meau = gson.fromJson(url, Meau.class);
return meau;
}
}
presenter
public class RequestPresenter {
private final DataCall dataCall;
private Handler handler = new Handler(Looper.getMainLooper()){
@Override
public void handleMessage(Message msg) {
Meau meau = (Meau) msg.obj;
if (meau.getCode() == 0){
dataCall.requestSuccess(meau);
}else {
dataCall.requestFail(meau);
}
}
};
public RequestPresenter(DataCall dataCall) {
this.dataCall = dataCall;
}
public void getRequest(final String url){
new Thread(new Runnable() {
@Override
public void run() {
Meau data = RequestModel.getData(url);
Message message = handler.obtainMessage();
Log.i("aaa1",data.toString());
message.obj = data;
handler.sendMessage(message);
}
}).start();
}
}