Este artículo comparte el código específico para la pantalla de compras de implementación de RxJava Retrofit para su referencia. El contenido específico es el siguiente
Muestre a todos las representaciones primero
Estructura de marco:
1. Marco del proyecto: MVP, la carga de imagen es realizada por Fresco, las solicitudes de red se implementan utilizando Okhttp+Retrofit (encapsularlo usted mismo, Agregar modo Singleton),
2. Complete la adición de datos del carrito de compras (si no hay datos en la interfaz, puede agregar datos utilizando la herramienta de interfaz).
3. Personalice la vista para implementar el botón Adición y resta. Cada vez que haga clic en Agregar y Restar, el número total y el precio total en el artículo deben cambiarse en consecuencia.
4. Cuando la cantidad es 1, haga clic en el signo menos, la cantidad permanece sin cambios y la tostada solicita al usuario que el número mínimo es 1.
5. El número total y el precio total en la parte inferior son el precio total y el número total en todos los artículos del artículo. Si se cambia el precio de la cantidad en cada artículo, el número total del precio total en la parte inferior debe estar vinculado a él.
6. Implemente la función de la selección inversa de opción única, ingrese la selección predeterminada por primera vez, el número total y el precio total no se incluyen en los datos inferiores cuando el elemento no está seleccionado. Cuando se cambia el estado seleccionado, el número total y el precio total de la parte inferior se pueden modificar correctamente.
7. Haga clic en el botón Eliminar para eliminar el elemento. El número total y el precio total en la parte inferior se pueden modificar correctamente, y los datos de la interfaz se eliminarán.
Agregar dependencias requeridas y permisos de redes
Compilar 'com.squareup.rcrofit2: moderning: 2.0.0-beta4' // paquete requerido Compile 'com.squareup.rrofit2: converter-gson: 2.0.0-beta4' // Compile de paquete de dependencia GSON de ConverterFactory 'com.squareup.rrecofit2: convertidor-scalars: 2.0.0-beta4' // ConverterFactory's String Dependency Package Compile 'Io.reactiveX.RXJava2: RxJava: 2.1.3'Compile' Io.reactiveX.RXJava2: Rxandroid: 2.0.1'1'compile 'Io.reactiveX.RxJava2: Rxandroid: 2.0.1'1'Compile 'com.squareup.rrofit2: adapter-rxjava2: 2.3.0'compile' de.greenrobot: eventbus: 3.0.0-beta1'compile 'com.facebook.fresco: fresco: 0.11.0'
<usos-permission android: name = "android.permission.internet" />
Subcontratarse antes de usar el modo MVP
paquete neto
API
API de clase pública {public static string host = "http://120.27.23.105/product/";}Serviceapi
Interfaz pública ServiceApi {@get ("getProductDetail") flujo de flujo <xqbean> getxq (@Query ("pid") int pid, @Query ("fuente) string str); @Get ("addCart") Flowable <DdCart> getMsg (@Query ("uid") int uid, @Query ("pid") int pid, @Query ("fuente) string str); @Get ("getcarts") fluable <artbean> getcart (@Query ("uid") int uid, @Query ("fuente") string str);}Interfaz exitosa
Interfaz pública OnnetLisenter <T> {Void Success (t t);}Envasado de modernización
clase pública retrofithepler {public static okhttpclient okhttpclient; Pública Serviceapi Serviceapi; / *** Ejecución de prioridad*/ static {gokokhttpclient (); } public static static okhttpClient gokokhttpclient () {if (okhttpclient == null) {sincronizado (okhttpclient.class) {if (okhttpclient == null) {okhttpclient = new OkhttpClient (); }} return okhttpClient; } public static Serviceapi getServiceApi () {if (serviceePi == null) {sincronizado (okhttpclient.class) {if (serviceapi == null) {serviceapi = onCreate (serviceapi.class, api.host); }}} return ServiceApi; } public static <t> t onCreate (class <t> tclass, string url) {retrofit retrofit = new Retrofit.Builder () .Baseurl (url) .addConverterFactory (gsonConverterFactory.create () .Client (okhttpclient) .addCalladapterFactory (rxJava2CalladapterFactory.Create ()) //. AddCalladapterFactory (rxJava2CalladapterFactory.Create ()) .Build (); return return.create (tcLass); }} paquete de frijoles
Clase de frijoles para más detalles
public class xqbean {/** * msg: * seller: {"Descripción": "Soy un comerciante 2", "icon": "http://120.27.23.105/images/icon.png", "nombre": "comerciante 2", "productos de productos": 999, "PRISTACIÓN": 5, "Sellerid": 2} Code: 0 * dats {"BargainPrice": 111.99, "CreateTime": "2017-10-14t21: 48: 08", "DetellUrl": "https://item.m.jd.com/product/4719303.html?utm_source=androidap&utm_medium=appshare&utm_campaign=t_t_ 335139774 & utm_term = qqfriends "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t9004/210/1160 833155/647627/AD6BE059/59B4F4E1N9A2B1532.JPG! Q70.JPG | https: //m.360buyimg.com/n0/jfs/t7 504/338/63721388/491286/f5957f53/598e95f1n7f2adb87.jpg! Q70.jpg | https: //m.360buyimg.co m/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbnd989ba0a.jpg! Q70.jpg "," itemtype ": 2 , "Pid": 9, "Precio": 78.99, "PScid": 1, "Salenum": 2356, "SellerID": 2, "Subhead": "Cada festival de mediados de alumno no puede ser simple. No importa dónde se encuentre, siempre necesita una tarta para hacer que su vida sea más completa, JD MoonCake hace que el Amor sea más completo, JD Efopeed, Lightning Delivery, más sorpresas, Pushes con su Cheet With Your Complete. Fingers "," Título ":" Beijing Daoxiangcun Daoxiangcun Festival Mid-Outumn Festival Mooncake Old Beijing Mooncake Gift Box 655g "} */ Private String Msg; Vendedor privado Vendedor; código de cadena privada; datos de datos privados; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } public SellerBean GetSeller () {Vendedor de retorno; } public void setSeller (SellerBean Seller) {this.seller = Seller; } public String getCode () {código de retorno; } public void setCode (código de cadena) {this.code = code; } public dataBean getData () {return data; } public void setData (datos de datos) {this.data = data; } public static class SellerBean {/** * Descripción: Soy un comerciante 2 * icono: http://120.27.23.105/images/icon.png * Nombre: comerciante 2 * productnums: 999 * Puntuación: 5.0 * SellerID: 2 */Descripción de cadena privada; icono de cadena privada; nombre de cadena privada; Private int productnums; puntaje doble privado; Private int Sellerid; public String getDescription () {return Descripción; } public void setDescription (String Descripción) {this.description = Descripción; } public String getiCon () {return icon; } public void seticon (icon de cadena) {this.icon = icon; } public String getName () {nombre de retorno; } public void setName (nombre de cadena) {this.name = name; } public int getProductnums () {return productNums; } public void setProductnums (int productnums) {this.productnums = productnums; } public Double GetScore () {puntaje de retorno; } public void setScore (doble puntaje) {this.score = stork; } public int getSellerID () {return SellerID; } public void setSellerID (int sellerid) {this.sellerID = sellerId; }} Public static Class Databean { /** * BargainPrice: 111.99 * CreateTime: 2017-10-14t21: 48: 08 * DetellUrl: https://item.m.jd.com/product/4719303.html?utm_source=androidApp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=qqkriends * Imágenes: https://m.360buyimg.com/n0/jfs/t9004/210/11608333155/647627/ad6be059/59b4 f4e1n9a2b1532.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t7504/338/63721 388/491286/f5957f53/598e95f1n7f2adb87.jpg! Q70.jpg | https: //m.360buyimg.co m/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbnd989ba0a.jpg! Q70.jpg * itemType: 2 * Pid: 9 * Precio: 78.99 * PSCID: 1 * Ventas: 2356 * SellerId: 2 * Subzule: Cada festival de mediana alumno no puede ser simple. No importa dónde se encuentre, siempre necesita un pedazo de pastel para que su vida sea más completa. JD Mooncakes hace que el amor sea más completo JD autoperado, entrega de relámpagos, más sorpresas, haga clic con su dedo * Título: Beijing Daoxiangcun Daoxiangcun Festival Mid-Autumn Festival Mooncake Old Beijing Mooncake Box 655g */ Double BargainPrice de doble negociación privada; Cadena privada CreateToTime; DetailUrl de cadena privada; Imágenes de cadena privada; Private int itemType; privado int pid; precio doble privado; privado int pscid; Private int Salesenum; Private int Sellerid; subtítulo de cadena privada; título de cadena privada; public Double GetBargainPrice () {return BargainPrice; } public void setBarGainPrice (doble compuesto de negociación) {this.BarGainPrice = BargainPrice; } public String getCreateTime () {return CreateTime; } public void setCreateTime (String CreateTime) {this.CreateTime = CreateTime; } public String getDetailUrl () {return DetailUrl; } public void setDetailUrl (cadena detallurl) {this.detailUrl = DetellUrl; } public String getImages () {return imágenes; } public void setImages (imágenes de cadena) {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 (doble precio) {this.price = precio; } public int getPscid () {return pscid; } public void setPscid (int pscid) {this.pscid = pscid; } public int getSalenum () {return salesEnum; } public void setSalenum (int salsenum) {this.salenum = salesenum; } 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 () {Título de retorno; } public void settitle (título de cadena) {this.title = title; }}}Frijol agregado al carrito
clase pública addcart {private string msg; código de cadena privada; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } public String getCode () {código de retorno; } public void setCode (código de cadena) {this.code = code; }}Categoría de productos
public class Cartbean { /*** msg: solicitud exitosa* Código: 0* Datos: [{"List": [{"BargainPrice": 22.9, "CreateTimeMe": "2017-10-14t21: 48: 08", "DetellUrl": "https://item.m.jd.com/product/2542855.html?utm_Source=androidApp & utm_medium = appShare & utm_campaign = t_335139774 & utm_term = qqfriends "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4// 56f0a08fnbd3a1235.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/2 802996626/155915/e5e90d7a/56f0a09cn33e01bd0.jpg! Q70.jpg | https: //m.360buy img.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2na0c86ea6.jpg ! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531a a913/57709035N33857877.jpg!q70.jpg","num":1,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"Three Squirrels snack special offer, 50 off for the area over 99, 100 off for the area over 199, hurry up and buy it 》 "," Título ":" Tres nueces de ardilla tostados tostados Pecan 225G/Bag "}, {" BargainPrice ": 11800," CreateTime ":" 2017-10-10t17: 33: 37 "," DetellUrl ":" https://item.m.jd.com/product/433381077 .html? utm#_source = androidapp & utm#_medium = appShare & utm#_campaign = t#_335139774 & utm#_term = qqriends "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t6700 /155/20989998076/156185/6cf95035/595dd5a5nc3a7dab5.jpg nelyq70.jpg","num":2, "," PID ": 57," Precio ": 5199," PScid ": 40," seleccionado ": 0," SellerID ": 1," Subhead ":" 【i5 MMX150 2G Memoria de video] Full HD Bisel estrecho 8G Memoria 256 SSD admite el reconocimiento de huellas dactilares Sistema Win10 preinstalado "," Título ":" Xiaomi (MI) Air 13.3 pulgadas Full Metal Thin Notebook (i5-7200U 8G 256G PCLE SSD MX150 2G Independent Graphics FHD Reconocimiento de escrutiones Finge Win10) Win10))) Silver/r/n "}, {" BargainPrice ": 99," CreateTimeMe ":" 2017-10-14t21: 38: 26 "," DetellUrl ":" https://item.m.jd.com/product/4345173.html?utm#_source=androidApp Share & Utm#_campaign = t#_335139774 & utm#_term = qqfriends "," Imágenes ":" https: //m.360buyimg .com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10na4ec7f39.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12ne3e6bc56.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12 N5b900606.jpg! Q70.jpg "," num ": 1," Pid ": 45," Precio ": 2999," PSCID ": 39," Seleccionado ": 0," SellerID ": 1," Subhead ":" HD Dual Camera, está claro! Monstruo! "," Título ":" OnePlus Mobile 5 (A5000) 6GB+64GB Yueyanhui Conexión completa de red dual dual móvil Mobile unicom Telecom 4g Teléfono móvil "}]," SellerName ":" Merchant 1 "," SellerId ":" 1 "}, {" List ": [{" 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 "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/ 59b857f2n6ca75622.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t9346/182/1406837243/28210 6/68AF5B54/59B8480ANE8AF7F5C.JPG! Q70.JPG | https: //m.360buyimg.com/n0/jfs/t8434/54/1359766 007/56140/579509d9/59b85801nfea207db.jpg! Q70.jpg "," num ": 1," pid ": 46," precio ": 234," pScid ": 39," seleccionado ": 0," Sellerid ": 2," subhead ":" Diferente "," Título ":" Apple iPhone 8 Plus (A1864) 64GB Golden Mobile Unicom Telecom 4G Mobile "}]," SellerName ":" Comerciante 2 "," SellerId ":" 2 "}, {" List ": [{" BargainPrice ": 111.99," CreateTime ":" 2017-10-03t23: 43: 53 "," DetailUrl ":" https://item.m.jd.com/Product/4719303.html?utm_source=android. utm_medium = appShare & utm_campaign = t_335139774 & utm_term = qqfriends "," Imágenes ":" 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/t7444/10/64242474/419246/adb30a7d/598e95fbnd989ba0a.jpg_scelq70.jpg",endo "PScid": 1, "Seleccionado": 0, "SellerId": 5, "Subhead": "Cada festival de mediados de alumno no puede ser simple. No importa dónde se encuentre, siempre necesita un pastel para hacer su vida más completa. JD Mooncakes hace que el amor sea más completo. JD autoapered, entrega de Lightning, más sorpresas, haga clic con sus dedos", "Title": ":" Beijing daoxiangcun DaoxiMcuncuncun. Festival Mooncake Old Beijing Mooncake Gift Box 655g "}]," SellerName ":" Merchant 5 "," SellerId ":" 5 "}, {" Lista ": [{" Bar GainPrice ": 11800," CreateTime ":" 2017-10-03T23: 53: 28 "," DetellUrl ":" https://mitem.jd.hk/ware/view.act ion? Wareid = 1988853309 & Cachekey = 1acb07a701eCe8d2434a6ae7fa6870a1 "," Imágenes ":" https://m.360buyimg.com/ N0/JFS/T6130/97/1370670410/180682/1109582a/593276b1nd81fe723.jpg! Q70.jpg | https: //m.360buyimg.com/n 0/JFS/T5698/110/2617517836/202970/c9388feb/593276b7nbd94ef1f.jpg! Q70.jpg | https: //m.360buyimg.com/n0 /jfs/t5698/110/2617517836/202970/c9388feb/593276b7nbd94ef1f.jpg )k70.jpg|https://m.360buyimg.com/n0 /jfs/t5815/178/2614671118/51656/7f52d137/593276c7n107b725a.jpg )k70.jpg|https://m.360buyimg.com/n0/j fs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":62,"price":15999,"pscid":40,"selected":0,"sellerid":6,"subhead":"Purchase some computer Productos de oficina para 1 yuan y regresar a los boletos de tren para 5 yuanes (una vez que termina la devolución) "," Título ":" Compra global de nuevos Apple Models MacBook Pro Apple Silver VP2 New de 13 pulgadas Bar i5/8g/256g "}]," SellerName ":" Comerciante: "Merchant 6 "," SellerID ":" 6 "}, {" List ": [{" BargainPrice ": 399," CreateTime ":" 2017-10-03t23: 53: 28 "," DetellUrl ":" https://item.m.jd.com/product/1439822107.html? utm_source = androidapp & utm_medium = appShare & utm_campaign = t_335139774 & utm_term = qqfriends " , "Imágenes": "https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24n e854e14c.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281 /59224C24N3324D5F4.JPG) 4/5c73d281/59224c24N3324d5f4.jpg!q70.jpg","num":1,"pid":86,"price":777,"pscid":85,"selected":0,"sellerid":7,"subhead":"2 pieces, total price is 65% off","title":"Gap men's casual, comfortable, simple wash Cinco bolsas de pantalones rectos Jeans ajustados 941825 Dark Grey 33/32 (175/84a) "}]," SellerName ":" Comerciante 7 "," SellerId ":" 7 "}, {" List ": [{" BargainPrice ": 111.99," CreateTime ":" 2017-10-14t21: 39: 05 "," DetailUrl: "https://item.m.jd.com/Prod.com/Prod.com/Prod.com/Prod.com/Prod.com/Prod.com/Prod.com/Prod.com/Prod UCT/4719303.html? Utm_source = androidApp & utm_medium = appShare & utm_campaign = t_335139774 & utm_term = qqfiends "," Imágenes ":" https: //m.36 0buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1n9a2b153 2.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f 5957f53/598e95f1n7f2adb87.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t74 41/10/64242474/419246/ADB30A7D/598E95FBND989BA0A.JPG! Q70.JPG "," NUM ":" P ID ": 1," Price ": 118," PScid ": 1," Seleccionado ":" SellerId ": 17," Subhead ":" Cada festival de medios, no puede ser simple. Daoxiangcun Festival Mid-Autumn Mooncake Old Beijing Mooncake Gift Box 655g "}]," SellerName ":" Merchant 17 "," SellerId ":" 17 "}, {" Lista ": [{" BargainPrice ": 111.99," Createtime ":" 2017-14t21: 39: 05 "," Detallerl ":" HOTTPS ":" HATTPSS: " : //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/59b4f4e1n9a2bbbb 1532.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t7504/338/63721388/491286 /f5957f53/598e95f1n7f2adb87.jpg) 7441/10/64242474/419246/adb30a7d/598e95fbnd989ba0a.jpg! Q70.jpg "," num ": 4, "Pid": 2, "Price": 299, "PScid": 1, "Seleccionado": 0, "SellerID": 18, "Subhead": "Cada festival de mediana alumno no puede ser simple. No importa dónde se encuentre, siempre necesita un pedazo de pastel para hacer su vida más completa, JD Mooncakes hace que el amor sea más completo, jd autooperado, Lightning Deliver Daoxiang Village Daoxiang Village Festival Mid-Autumn Festival Mooncake Old Beijing Mooncake Gift Box 655g "}]," SellerName ":" Comerciante 18 "," SellerId ":" 18 "}, {" 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/1 370670410/180682/1109582a/593276b1nd81fe723.jpg! Q70.jpg | https: //m.360buy img.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7nbd94ef1f.jp G! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c93 88feb/593276b7nbd94ef1f.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t5815/ 178/2614671118/51656/7f52d137/593276c7n107b725a.jpg! Q70.jpg | https: //m.36 0buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276can5a7d6357. jpg! Q70.jpg "," num ": 1," pid ": 76," precio ": 37999.99," pScid ": 40," seleccionado ": 0," vellerId ": 20," subhead ":" compra algunos productos de oficina de computadora para 1 yuan y obtenga un cupón 5 yuan para entradas de entrenamiento (una vez que se acabó) ",", "Título": "Título": "Título de" " VP2 Nuevo bar de 13 pulgadas i5/8g/256g "}]," SellerName ":" Comerciante 20 "," SellerId ":" 20 "}, {" List ": [{" BargainPrice ": 111.99," CreateTime ":" 2017-10-14t21: 39: 05 "," DetailUrl ":" https://item.m.jd.com/product/4719303.html?utm_source=androroid. p & utm_medium = appShare & utm_campaign = t_335139774 & utm_term = qqfriends "," Imágenes ":" 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 ": 5," pric " E ": 88.99," PSCID ": 1," Seleccionado ":" SellerId ": 21," Subhead ":" Cada festival de medios en el ESE. Daoxiangcun Festival Mid-Outumn Mooncake Old Beijing Mooncake Regalo Box 655g "}]," SellerName ":" Merchant 21 "," SellerId ":" 21 "}]] */ String private String msg; código de cadena privada; Lista privada <TaTabean> datos; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } public String getCode () {código de retorno; } public void setCode (código de cadena) {this.code = code; } Lista pública <TataBean> getData () {return data; } public void setData (list <satabean> data) {this.data = data; } Public Static Class Databean { /*** List: [{"GargainPrice": 22.9, "CreateTeTime": "2017-10-14t21: 48: 08", "DetellUrl": "https://item.m.jd.com/product/2542855.html?utm_source=androidp&utm_med ium = appShare & utm_campaign = t_335139774 & utm_term = qqfriends "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08 fnbd3a1235.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/2802996 626/155915/e5e90d7a/56f0a09cn33e01bd0.jpg! Q70.jpg | https: //m.360buyimg. OM/N0/JFS/T1882/31/2772215910/389956/C8DBF370/56F0A0A2NA0C86EA6.JPG! P70 .jpg | https: //m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913 /57709035n33857877.jpg) 》》 "," Título ":" Tres nueces de ardilla tostados tostados nuez 225g/bag "}, {" BargainPrice ": 11800," CreateTime ":" 2017-10-10t17: 33: 37 "," DetailUrl ":" https://item.m.jd.com/product/43338107.hhhhh. tml? utm#_source = androidapp & utm#_medium = appShare & utm#_campaign = t#_335139774 & utm#_term = qqfriends "," Imágenes ":" https://m.360buyimg.com/n0/jfs/t6700/ 155/20989998076/156185/6CF95035/595DD5A5NC3A7DAB5.JPG! Q70.JPG "," NUM ": 2," PID ": 57," precio ": 5199," PScid ": 40," seleccionado ":" vendedor ": 1: 1," Subeficiente ":" 【【【【【【【【【【【【【【【【【【【. MMX150 2G Memoria de video] Full HD Bisel estrecho 8G Memoria 256 SSD admite el reconocimiento de huellas dactilares Sistema Win10 preinstalado "," Título ":" Xiaomi (MI) Air 13.3 pulgadas Full Metal Thin Notebook (i5-7200U 8G 256G PCLE SSD MX150 2G Independent Graphics FHD Reconocimiento de escrutiones Finge Win10) Win10))) Silver/r/n "}, {" BargainPrice ": 99," CreateTimeMe ":" 2017-10-14t21: 38: 26 "," DetellUrl ":" https://item.m.jd.com/product/4345173.html?utm#_source=androidApp Share & Utm#_campaign = t#_335139774 & utm#_term = qqfriends "," Imágenes ":" https: //m.360buyimg .com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10na4ec7f39.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12ne3e6bc56.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12 N5b900606.jpg! Q70.jpg "," num ": 1," Pid ": 45," Precio ": 2999," PSCID ": 39," Seleccionado ": 0," SellerID ": 1," Subhead ":" HD Dual Camera, está claro! Monster! Vendedor de cadenas privadas; Lista de lista privada <Listbean>; cheque booleano privado; public boolean isCheck () {return check; } public void setCheck (cheque boolean) {this.eck = check; } 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; } Lista pública <LiCBean> getList () {return List; } public void setList (list <IndBean> 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=qqqfriends * Imágenes: 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/27722215910/389956/c8dbf370/56f0a0a2na0c86ea6.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2620/166/27038333710/312660/531aa913/57709035n333857877.jpg! Q70.jpg * NUM: 1 * PID: 24 * Precio: 288.0 * PSCID: 2 * Seleccionado: 0 * Vendedor: 1 * Suboficial: Tres bocadillos de ardilla Oferta especial, 50 de descuento para compras de más de 99 en el área, 100 de descuento para compras sobre 199 en el área, apúrate y compra》 * Título de tres cervezas de ardillas. Cadena privada CreateToTime; DetailUrl de cadena privada; Imágenes de cadena privada; privado int num; privado int pid; precio doble privado; privado int pscid; private int seleccionado; Private int Sellerid; subtítulo de cadena privada; título de cadena privada; privado int co co = 1; public int getCou () {return cou; } public void setCou (int cou) {this.cou = coU; } cheque booleano privado; public boolean isCheck () {return check; } public void setCheck (cheque boolean) {this.eck = check; } public Double GetBargainPrice () {return BargainPrice; } public void setBarGainPrice (doble compuesto de negociación) {this.BarGainPrice = BargainPrice; } public String getCreateTime () {return CreateTime; } public void setCreateTime (String CreateTime) {this.CreateTime = CreateTime; } public String getDetailUrl () {return DetailUrl; } public void setDetailUrl (cadena detallurl) {this.detailUrl = DetellUrl; } public String getImages () {return imágenes; } public void setImages (imágenes de cadena) {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 (doble precio) {this.price = precio; } public int getPscid () {return pscid; } public void setPscid (int pscid) {this.pscid = pscid; } public int getSelected () {return seleccionado; } public void setSelected (int seleccionado) {this.selected = seleccionado; } 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 () {Título de retorno; } public void settitle (título de cadena) {this.title = title; }}}} aplicación
public class MyApp extiende la aplicación {@Override public void onCreate () {super.oncreate (); Fresco.initialize (esto); }} Ver capa
Escribe dos interfaces primero
Interfaz pública ICART {void showList (List <CartBean.databean> GroupList, List <List <CartBean.databean.listbean >> ChildList);} interfaz pública iview <t> {void showbean (t t); void showstr (string s);}Diseño de la página principal
<? xml versión = "1.0" encoding = "utf-8"?> <linealLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: app = "http://schemas.android.com/apk/res-auto xmlns: herramientas = "http://schemas.android.com/tools" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" Android: Orientación = "VERTICAL" Herramient Android: id = "@+id /elv" Android: Layout_weight = "1" Android: Layout_width = "wrap_content" Android: Layout_height = "wrap_content" /> <linealLayout android: layout_weight = "9" Android: orientación = "horizontal" android: layout_width = "Match_parent" Android: Layout_height = "Match_Parent"> <CheckBox android: id = "@+id /quanxuan" Android: Layout_width = "wrap_content" android: layout_height = "wrap_content" /> <textView android: text = "Select thel" android: layout_width = "wrap_content" " Android: Layout_height = "wrap_content" /> <linealLayout android: layout_marginleft = "50dp" android: orientation = "vertical" android: layout_width = "wrap_content" android: layout_height = "wrap_content"> <extegieid: id = "@+id /zongjia" Android: Layout_width = "wrap_content" Android: Layout_height = "wrap_content" Android: text = "Total Price: 0.0" /> <TextView Android: Text = "Total 0 elementos" Android: id = "@+id /TV_Count" Android: Layout_Width = "WRAP_CONTENT" Android: LayOut_Height "wrap_content" </LinearLayout> <TextView Android: Text = "Total Checkout" Android: Background = "#FFD82020" Android: Layout_marginleft = "100dp" Android: Layout_width = "wrap_content" android: layout_height = "wrap_content"/> </lineLayout> </lineArLayout>
Página principal
La clase pública MainActivity extiende AppCompatactivity implementos ICART {private expandableListView melv; casilla de verificación privada MQUANXUAN; TextView privado Mzongjia; TextView privado MTVCount; MyExPandableAdapter privado MyExPandableAdapter; @Override protegido void onCreate (Bundle SaveDInStancestate) {super.oncreate (saveDInStancestate); setContentView (r.layout.activity_main); initView (); nuevo CartPresenter (this) .getcart (); EventBus.getDefault (). Registro (este); Mquanxuan.setOnClickListener (new View.OnClickListener () {@Override public void onClick (View V) {myExPandableAdapter.qx (mquanxuan.ischecked ());}}); } private void initView () {melv = (expandableLeStView) findViewById (r.id.elv); MQUANXUAN = (casilla de verificación) findViewByid (r.id.quanxuan); mzongjia = (textView) findViewByid (r.id.zongjia); mtvcount = (textView) findViewByid (r.id.tv_count); } @Override public void showList (List <CartBean.databean> GroupList, List <List <CartBean.databean.listbean >> ChildList) {MyExPandableArtePter = new MyExPandableAdapter (Groupplist, this, ChildList); Melv.SetAdapter (myExPandableAdapter); for (int i = 0; i <groupList.size (); i ++) {melv.expandgroup (i); }} // Recibe el valor transmitido @SubScribe public void onPricece yCount (count yPrice cp) {mzongjia.settext ("total"+cp.getCount ()+"item"); mtvcount.setText ("Total:"+cp.getPrice ()); } // Recibe el valor transmitido @SubScribe public void onPneDCount1 (Evento MessgeEvent) {// Cambia el estado seleccionado MQUANXUAN.Setchecked (event.ischeck ()); } @Override Protected Void OnDestrOY () {super.onstroy (); EventBus.getDefault (). Unregister (esto); }}El diseño de la segunda página
<? xml versión = "1.0" encoding = "utf-8"?> <linealLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: herramientas = "http://schemas.android.com/tools" android: lectout_width = "Match_arent" Android: Layout_height = "Match_parent" Android: Orientation = "Vertical" Android: id = "@+id/Activity_add" Herramientas: context = "com.bwie.zhangzhen20170108.addactivity"> <Com.facebook.drawee.view.simpledraweeView Android: lectout_width = "30000DP" 30000Dp " Android: id = "@+id /xqsdv1" android: layout_gravity = "Center" Android: Layout_height = "300DP" /> <TextView Android: id = "@+id /tvtitle1" Android: Layout_width = "Match_Parent" Android: LayOut_Height = "WRAP_CONTENT" /> <Linearout_width = "Match_parent" Android: orientación = "horizontal" android: lazout_width = "match_parent" android: loinout_height = "wrap_content"> <botón android: id = "@+id/tiaozhuan1" Android: Layout_weight = "1" Android: Text = "Jump to Cart" Android: Layout_width = "Match_parent" Android: Layout_height = "Wrap_Content"/> <Button Android: id = "@+id/Tianjia1" Android: Layout_weight = "1" Android: Text = "Agregar a CART" Android: Layout_Width = "Match_Parent" Android: Layout_height = "wrap_content"/> </linearLayout> </lineLapeOut>
Implementación del código del carrito de compras
public class AddActivity extiende AppCompatactivity implementos View.OnClickListener, IView {private SimpledRaweEview mxqsdv; TextView privado mtvtitle; botón privado Mtiaozhuan; botón privado Mtianjia; Private LinealLayout Maddactivity; Privado XQPresenter XQPresenter; @Override protegido void onCreate (Bundle SaveDInStancestate) {super.oncreate (saveDInStancestate); setContentView (r.layout.activity_add); initView (); xqPresenter = new XqPresenter (esto); xqPresenter.getxq (); } private void initView () {mxqsdv = (simpledraweEview) findViewByid (r.id.xqsdv1); mtvtitle = (textView) findViewByid (r.id.tvtitle1); mtiaozhuan = (botón) findViewByid (r.id.tiaozhuan1); mtiaozhuan.setOnClickListener (esto); mtianjia = (botón) findViewByid (r.id.tianjia1); mtianjia.setOnClickListener (esto); maddactivity = (linealLayout) findViewByid (r.id.activity_add); } @Override public void onClick (ver v) {switch (v.getid ()) {default: break; //Skip to MainActivity (Shopping Cart) case R.id.tiaozhuan1: startActivity(new Intent(this,MainActivity.class)); romper; case R.id.tianjia1: xqPresenter.getAdd(); romper; } } @Override public void showBean(Object o) { XQBean xqBean = (XQBean) o; XQBean.DataBean data = xqBean.getData(); String s = data.getImages().split("//|")[0]; Uri uri =Uri.parse(s);//Address converted to URI mXqsdv.setImageURI(uri); mTvtitle.setText(data.getTitle()+"/n"+data.getPrice()); } @Override public void showStr(String s) { Toast.makeText(this, s, Toast.LENGTH_SHORT).show(); }} eventbus包
设置一个数量和价格的类
public class CountAndPrice { private int count ; private int price; public int getCount() { return count; } public void setCount(int count) { this.count = count; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; }}EventBus
public class MessgeEvent { private boolean check; public boolean isCheck() { return check; } public void setCheck(boolean check) { this.check = check; }} modelo
实现详情页model层的接口
public interface IXQModel { public void getXQ(int pid, String str, final OnNetLisenter<XQBean> cgsb);}实现详情页model
public class XQModel implements IXQModel{ @Override public void getXQ(int pid, String str, final OnNetLisenter<XQBean> onNetLisenter) { Flowable<XQBean> flowable = RetrofitHepler.getSerViceAPI().getXQ(pid, str); flowable.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<XQBean>() { @Override public void accept(XQBean xqBean) throws Exception { onNetLisenter.Success(xqBean); } }); } public void getAdd(int uid, int pid, String str, final OnNetLisenter<AddCart> onNetLisenter){ Flowable<AddCart> flowable = RetrofitHepler.getSerViceAPI().getMsg(uid, pid, str); flowable.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<AddCart>() { @Override public void accept(AddCart addCart) throws Exception { onNetLisenter.Success(addCart); } }); }}购物车的model
public class CartModel { public void getCart(int uid, String str, final OnNetLisenter<CartBean> onNetLisenter){ Flowable<CartBean> flowable = RetrofitHepler.getSerViceAPI().getCart(uid,str); flowable.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new Consumer<CartBean>() { @Override public void accept(CartBean cartBean) throws Exception { onNetLisenter.Success(cartBean); } }); }} presenter层
详情页的P层
public class XQPresenter { private final XQModel xqModel; private IView iView; public XQPresenter(IView iView) { xqModel = new XQModel(); this.iView=iView; } public void getXQ(){ xqModel.getXQ(12, "android", new OnNetLisenter<XQBean>() { @Override public void Success(XQBean xqBean) { iView.showBean(xqBean); } }); } public void getAdd(){ xqModel.getAdd(3043, 12, "android", new OnNetLisenter<AddCart>() { @Override public void Success(AddCart addCart) { iView.showStr(addCart.getMsg()); } }); }}购物车的P层
public class CartPresenter { private ICart iCart; private final CartModel cartModel; public CartPresenter(ICart iCart) { this.iCart = iCart; cartModel = new CartModel(); } public void getCart(){ cartModel.getCart(3043,"android",new OnNetLisenter<CartBean>(){ @Override public void Success(CartBean cartBean) { List<CartBean.DataBean> grouplist = cartBean.getData(); List<List<CartBean.DataBean.ListBean>> childlist = new ArrayList<>(); for (int i = 0; i < grouplist.size(); i++) { CartBean.DataBean dataBean = grouplist.get(i); List<CartBean.DataBean.ListBean> list = dataBean.getList(); childlist.add(list); } iCart.showlist(grouplist,childlist); } }); }}adaptador
public class MyExpandableAdapter extends BaseExpandableListAdapter { private List<CartBean.DataBean> groupdata; private Context context; private List<List<CartBean.DataBean.ListBean>> childlist; public MyExpandableAdapter( List<CartBean.DataBean> groupdata, Context context, List<List<CartBean.DataBean.ListBean>> childlist) { this.groupdata = groupdata; this.context = context; this.childlist = childlist; } @Override public int getGroupCount() { return groupdata.size(); } @Override public int getChildrenCount(int groupPosition) { return childlist.get(groupPosition).size(); } @Override public Object getGroup(int groupPosition) { return groupdata.get(groupPosition); } @Override public Object getChild(int groupPosition, int childPosition) { return null; } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public boolean hasStableIds() { return false; } @Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { final GroupViewHolder holder; if (convertView == null) { convertView = View.inflate(context, R.layout.group_item, null); holder = new GroupViewHolder(); holder.tv_group = (TextView) convertView.findViewById(R.id.tv_group); holder.group_cb = (CheckBox) convertView.findViewById(R.id.gx_group); convertView.setTag(holder); } else { holder = (GroupViewHolder) convertView.getTag(); } final CartBean.DataBean dataBean = groupdata.get(groupPosition); String sellerName = dataBean.getSellerName(); holder.group_cb.setChecked(dataBean.isCheck()); //Click the status of the first-level checkbox holder.group_cb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dataBean.setCheck(holder.group_cb.isChecked()); //Change the status of all children changeChildState(groupPosition,holder.group_cb.isChecked()); EventBus.getDefault().post(jS()); //Judge the status of all selected by judging the checkbox of the first level changeMianQXstatus(checkGroupAll()); notifyDataSetChanged(); } }); return convertView; } @Override public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { final ChildViewHolder holder; if (convertView == null) { convertView = View.inflate(context, R.layout.child_item, null); holder = new ChildViewHolder(); holder.tv_title= (TextView) convertView.findViewById(R.id.title); holder.price= (TextView) convertView.findViewById(R.id.price); holder.child_cb= (CheckBox) convertView.findViewById(R.id.gouxuan_child); holder.add= (TextView) convertView.findViewById(R.id.jia); holder.del= (TextView) convertView.findViewById(R.id.del); holder.jian= (TextView) convertView.findViewById(R.id.jian); holder.sdv= (SimpleDraweeView) convertView.findViewById(R.id.title_img); holder.tv_num= (TextView) convertView.findViewById(R.id.tv_num); holder.yanse= (TextView) convertView.findViewById(R.id.yanse); convertView.setTag(holder); } else { holder = (ChildViewHolder) convertView.getTag(); } final CartBean.DataBean.ListBean listBean = childlist.get(groupPosition).get(childPosition); int price = (int) listBean.getPrice(); holder.child_cb.setChecked(listBean.isCheck()); holder.price.setText("¥:"+price+""); String title = listBean.getTitle(); holder.tv_title.setText(title); String subhead = listBean.getSubhead(); String substring = subhead.substring(1, 10)+"......"; holder.yanse.setText(substring); String images = listBean.getImages(); String[] split = images.split("//|"); String s = split[0]; Uri uri=Uri.parse(s); holder.sdv.setImageURI(uri); // listBean.setCou(Integer.parseInt(holder.tv_num.getText().toString())); // checkBox click event holder.child_cb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listBean.setCheck(holder.child_cb.isChecked()); EventBus.getDefault().post(jS()); //If the checkBox of the second level is selected, let the checkBox of the first level checkBox check if(holder.child_cb.isChecked()) { if (ischeckAllchild(groupPosition)) { //Change the status of the first level checkBox changeGroupstatus(groupPosition,true); //Change the status of the selected state by judging the status of the first level CheckBox to changeMianQXstatus(checkGroupAll()); } }else{ changeGroupstatus(groupPosition,false); changeMianQXstatus(checkGroupAll()); } notifyDataSetChanged(); } }); //Click add function holder.add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int cou = listBean.getCou(); holder.tv_num.setText(++cou+""); listBean.setCou(cou); if(holder.child_cb.isChecked()){ EventBus.getDefault().post(jS()); } } }); //Click the function of decreasing holder.jian.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int cou = listBean.getCou(); if(cou==1) { Toast.makeText(context, "The minimum number is 1", Toast.LENGTH_SHORT).show(); return;} holder.tv_num.setText(--cou+""); listBean.setCou(cou); if (holder.child_cb.isChecked()) { EventBus.getDefault().post(jS()); } } }); //Click to delete holder.del.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { List<CartBean.DataBean.ListBean> listBeen = childlist.get(groupPosition); CartBean.DataBean.ListBean remove = listBeen.remove(childPosition); if(listBeen.size()==0){ childlist.remove(childPosition); groupdata.remove(groupPosition); } EventBus.getDefault().post(jS()); notifyDataSetChanged(); } }); return convertView; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } class GroupViewHolder { CheckBox group_cb; TextView tv_group; } class ChildViewHolder { CheckBox child_cb; TextView tv_title,price,yanse,tv_num; TextView del,add,jian; SimpleDraweeView sdv; } /** * Determine that all the second level is CheckBox or not checked* */ private boolean ischeckAllchild(int g){ List<CartBean.DataBean.ListBean> listBeen = childlist.get(g); for (int i = 0; i <listBeen.size() ; i++) { CartBean.DataBean.ListBean listBean = listBeen.get(i); if(!listBean.isCheck()){ return false; }} return verdadero; } /** * Calculate quantity and price* Get the second-level CheckBox by traversing the first-level. If it is the selected selected state, count their total quantity and price*/ private CountAndPrice jS(){ int cou=0; int jiage=0; for (int i = 0; i <groupdata.size() ; i++) { for (int j = 0; j <childlist.get(i).size() ; j++) { CartBean.DataBean.ListBean listBean = childlist.get(i).get(j); if(listBean.isCheck()){ cou+=listBean.getCou(); jiage+=(int)listBean.getPrice()*listBean.getCou(); } } } } CountAndPrice countAndPrice = new CountAndPrice(); countAndPrice.setCount(cou); countAndPrice.setPrice(jiaage); return countAndPrice; } /** * Change the status of the first-level list*/ private void changeGroupstatus(int groupPosition,boolean flag ){ CartBean.DataBean dataBean = groupdata.get(groupPosition); dataBean.setCheck(flag); } /** * Change the status of all selected* */ private void changeMianQXstatus(boolean flag){ MessgeEvent messageEvent = new MessgeEvent(); messageEvent.setCheck(flag); EventBus.getDefault().post(messgeEvent); } /** * Determine whether all the first level are selected*/ private boolean checkGroupAll(){ for (int i = 0; i < groupdata.size(); i++) { if(!groupdata.get(i).isCheck()){ return false; }} return verdadero; } /** * Change the status of all children*/ private void changeChildState(int grouPistion,boolean flag){ List<CartBean.DataBean.ListBean> listBeen = childlist.get(grouPistion); for (int i = 0; i < listBeen.size(); i++) { listBeen.get(i).setCheck(flag); } } /** * Change all selected*/ public void qx(boolean flag){ for (int i = 0; i < groupdata.size(); i++) { changeGroupstatus(i, flag); changeChildState(i, flag); } EventBus.getDefault().post(jS()); notifyDataSetChanged(); }}group_item.xml
<?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"> <CheckBox android:id="@+id/gx_group" android:focusable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_group" android:layout_width="wrap_content" android:layout_height="wrap_content" /></LinearLayout>
child_item.xml
<?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="vertical"> <TextView android:id="@+id/title" android:layout_marginLeft="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" /> <LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <CheckBox android:layout_marginLeft="20dp" android:gravity="center_vertical" android:id="@+id/gouxuan_child" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <com.facebook.drawee.view.SimpleDraweeView android:gravity="center_vertical" android:id="@+id/title_img" android:layout_width="50dp" android:layout_height="50dp" /> <LinearLayout android:orientation="vertical" android:layout_marginLeft="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/price" android:layout_marginLeft="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/yanse" android:layout_marginLeft="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:layout_marginLeft="100dp" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/jian" android:layout_width="20dp" android:layout_height="20dp" android:textSize="15sp" android:text="一"/> <TextView android:id="@+id/tv_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:paddingBottom="2dp" android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="2dp" android:text="1" /> <TextView android:id="@+id/jia" android:layout_width="20dp" android:layout_height="20dp" android:layout_marginLeft="5dp" android:text="+" android:textSize="15sp"/> </LinearLayout> </LinearLayout> <TextView android:id="@+id/del" android:layout_marginLeft="20dp" android:text="删除" android:textColor="#FFFFFF" android:background="#ff3660" android:layout_width="32dp" android:layout_height="29dp" /> </LinearLayout></LinearLayout>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。