Cet article partage le code spécifique de l'affichage de panier d'achat d'implémentation Rxjava Retrofit pour votre référence. Le contenu spécifique est le suivant
Montrez d'abord à tout le monde les rendus
Structure du cadre:
1. Frame de projet: MVP, le chargement d'image est effectué par fresque, les demandes de réseau sont implémentées à l'aide de la rétrofit OKHTTP + (encapsulez-la vous-même, ajoutez le mode Singleton),
2. Complétez l'ajout de données de panier (s'il n'y a pas de données sur l'interface, vous pouvez ajouter des données à l'aide de l'outil d'interface).
3. Personnalisez la vue pour implémenter le bouton Ajout et soustraction. Chaque fois que vous cliquez sur Add et Soustraire, le nombre total et le prix total dans l'élément doivent être modifiés en conséquence.
4. Lorsque la quantité est 1, cliquez sur le signe moins, la quantité reste inchangée et le toast invite l'utilisateur que le nombre minimum est 1.
5. Le nombre total et le prix total en bas sont le prix total et le nombre total dans tous les articles. Si le prix de quantité dans chaque article est modifié, le nombre total du prix total en bas doit y être lié.
6. Implémentez la fonction de la sélection inverse à choix unique, entrez la sélection par défaut pour la première fois, le nombre total et le prix total ne sont pas inclus dans les données inférieures lorsque l'élément n'est pas sélectionné. Lorsque l'état sélectionné est modifié, le nombre total et le prix total du bas peuvent être modifiés correctement.
7. Cliquez sur le bouton Supprimer pour supprimer l'élément. Le nombre total et le prix total en bas peuvent être modifiés correctement et les données d'interface seront supprimées.
Ajouter des dépendances et des autorisations de réseautage requises
compiler 'com.squareup.retrofit2: rétrofit: 2.0.0-beta4' // Retrofit2 requise package compile 'com.squareup.retrofit2: converter-gon: 2.0.0-beta4' // converterfactory's gson Dependencs package compile compile pack 'com.squareup.RetRofit2: Converter-Scalars: 2.0.0-beta4' // Compilation du package de dépendance à chaîne de ConverterFactory 'io.reactivex.rxjava2: rxjava: 2.1.3'compile' io.Rxjava.rxjava: Rxandroid: 2.0.1 ' 'com.squareup.retrofit2: adaptateur-rxjava2: 2.3.0'compile' de.greenrobot: eventbus: 3.0.0-beta1'compile 'com.facebook.fresco: Fresco: 0.11.0'
<use-permission Android: name = "android.permission.internet" />
Sous-traitance avant d'utiliser le mode MVP
package net
API
classe publique API {public static String host = "http://120.27.23.105/product/";}ServiceApi
Interface publique ServiceAPI {@get ("getProductDetail") Flowable <xqbean> getXQ (@Query ("PID") int pid, @Query ("Source") String str); @Get ("addcart") Flowable <DdCart> getmsg (@Query ("uid") int uid, @Query ("pid") int pid, @Query ("Source") String str); @Get ("getCarts") Flowable <CartBean> getCart (@Query ("uid") int uid, @Query ("Source") String Str);}Interface réussie
Interface publique ONNETLISENTER <T> {VOID Success (T T);}Rénovation d'emballage
classe publique RetroFithePler {public static okhttpclient okhttpclient; SERVICEAPI STATIQUE PUBLIQUE; / ** * Exécution de priorité * / statique {getOKHttpClient (); } public static okhttpclient getOKHttpClient () {if (okhttpclient == null) {synchronisé (okhttpclient.class) {if (okhttpclient == null) {okhttpclient = new okhttpclient (); }} return okhttpclient; } public static ServiceAPI getServiceAPI () {if (ServiceAPI == null) {synchronisé (okhttpclient.class) {if (ServiceAPI == null) {ServiceAPI = onCreate (ServiceAPI.class, api.host); }}} return ServiceAPI; } public static <t> t onCreate (class <t> tclass, string url) {ragenrofit restrofit = new restrofit.builder () .baseUrl (url) .addConverterFactory (gsonconverterfactory.create ()) .client (okhttpclient) .AddCalladapterFactory (rxjava2CalladapterFactory.create ()) //. addCalladapterFactory (rxjava2CalladapterFactory.create ()) .build (); return return.create (tclass); }} paquet de haricots
Classe Bean pour les détails de la page
classe publique xqbean {/ ** * msg: * vendeur: {"Description": "Je suis un marchand 2", "icon": "http://120.27.23.105/images/icon.png", "name": "Merchant 2", "Productnums": 999, "Score": 5, "SellerId": 2} * Code: 0 * Données: Données: Data: {"Bargainprice": 111.99, "CreateTime": "2017-10-14t21: 48: 08", "DetailUrl": "https://item.m.jd.com/product/4719303.httml?utm_source=TAPP&EMPSH=Appshare&utm_campaign-great_ 335139774 & utm_term = qqfriends "," images ":" 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, "Price": 78.99, "PSCID": 1, "Salenum": 2356, "Sellerid": 2, "Sous-idi les doigts "," titre ":" Beijing daoxiangcun daoxiangcun Mid-Automm Festival Mooncake Old Beijing Mooncake Box Box 655G "} * / private String msg; Vendeur de vendeur privé; code de chaîne privé; données de données privées; String public getmsg () {return msg; } public void setmsg (String msg) {this.msg = msg; } public SellerBean getseller () {return vendeur; } public void SetSeller (vendeur vendeur) {this.seller = vendeur; } public String getCode () {return code; } public void setCode (String code) {this.code = code; } public dataean getData () {return data; } public void setData (dataean data) {this.data = data; } Classe statique publique SellerBean {/ ** * Description: Je suis un marchand 2 * icon: http://120.27.23.105/images/icon.png * Nom: Merchant 2 * Productnums: 999 * Score: 5.0 * Sellerid: 2 * / Private String Description; Icône de chaîne privée; nom de chaîne privé; Private Int Productnums; double score privé; private int Sellerid; public String getDescription () {return Description; } public void setDescription (String Description) {this.description = Description; } public String genicon () {return icon; } public void seticon (icône de chaîne) {this.icon = icon; } public String getName () {Nom de retour; } public void setName (string name) {this.name = name; } public int getProductNums () {return productNums; } public void setProductNums (int productNums) {this.productNums = productNums; } public double getScore () {return score; } public void setScore (double score) {this.score = score; } public int getSellerid () {return Sellerid; } public void SetSellerid (int Sellerid) {this.sellerid = seleDid; }} Classe statique publique Dataean {/ ** * 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=qqffriends * Images: https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/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 * Prix: 78,99 * PSCID: 1 * Ventes: 2356 * Sellerid: 2 * Sous-tête: Chaque festival du milieu de l'automne ne peut pas être simple. Peu importe où vous êtes, vous avez toujours besoin d'un morceau de gâteau pour vous rendre la vie plus complète. Les gâteaux de lune JD rendent l'amour plus complet jd auto-opéré, livraison de foudre, plus de surprises, veuillez cliquer avec votre doigt * Titre: Beijing Daoxiangcun Daoxiangcun Mid-Automn Festival Mooncake Old Beijing Mooncake Box 655G * / Private Double BargainPrice; Création de chaîne privée; DetailUrl de chaîne privée; images de chaîne privées; INT PRIVATE ITEMTYPE; Int Pid privé; double prix privé; Int privé PSCID; private int SalesNum; private int Sellerid; Sous-tête de chaîne privée; titre de chaîne privée; public double getBargainPrice () {return BargainPrice; } public void setBargainPrice (double bargainprice) {this.bargainprice = bargainprice; } public String getCreateTime () {return CreateTime; } public void SetCreateTime (String CreateEtime) {this.createTime = CreateTime; } public String getDetailUrl () {return DetailUrl; } public void setDetailUrl (String DetailUrl) {this.detailUrl = DetailUrl; } public String getImages () {return images; } public void setimages (chaîne 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 () {prix de retour; } public void setPrice (double prix) {this.price = prix; } public int getpscid () {return pscid; } public void setpscid (int pscid) {this.pscid = pscid; } public int getSalenum () {return SalesNum; } public void setsalenum (int vendenum) {this.salenum = vendenum; } public int getSellerid () {return Sellerid; } public void SetSellerid (int Sellerid) {this.sellerid = seleDid; } public String getSubhead () {return subhead; } public void setSubhead (String Subhead) {this.subhead = sous-ivale; } public String getTitle () {return title; } public void SettItle (String Title) {this.title = title; }}}Haricot ajouté au chariot
classe publique addCart {private String msg; code de chaîne privé; String public getmsg () {return msg; } public void setmsg (String msg) {this.msg = msg; } public String getCode () {return code; } public void setCode (String code) {this.code = code; }}Catégorie de produits
classe publique CartBean {/ ** * msg: demandez le succès * Code *: 0 * Données: [{"list": [{"Bargainprice": 22.9, "CreateTime": "2017-14t21: 48: 08", "DetailUrl": "https://item.m.jd.com/product/2542855.html?utm_source=androidApp & utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," images ":" https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/ 56f0a08fnbd3a1235.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/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," Prix ": 288," PSCID ": 2," Selected ": 0," Sellerid ": 1," Sous-ivale 》 "," Title ":" Three Squirrel Nuts Rolated Snacks Creamy Pecan 225G / Bag "}, {" Bargainprice ": 11800," CreateTime ":" 2017-10-10t17: 33: 37 "," DetailUrl ":" https://item.m.jd.com/product/4338107 .html? UTM # _Source = AndroidApp & utm # _medium = appshare & utm # _campaign = t # _335139774 & utm # _term = qqfriends "," images ":" https://m.360buyimg.com/n0/jfs/t6700 /155/2098998076/156185/6CF95035/595DD5A5NC3A7DAB5.jpg!q70.jpg" ,"num":2, " PID ": 57," Prix ": 5199," PSCID ": 40," Sélectionné ": 0," Sellerid ": 1," Sous-caisse ":" 【i5 Mémoire vidéo MX150 2G] Mémoire de lunette 8G étroite Full HD 256 SSD prend en charge la reconnaissance digitale du système Win10 préinstallé "," Title ":" Xiaomi (MI) AIR 13.3 pouces Full Metal Thin Notebook (i5-7200U 8G 256G PCLE SSD MX150 2G Independent graphiques indépendants Fhd Recognition Win10) Fhd Fhd-Ringer-empreinte Win10)) Silver / r / n "}, {" BargainPrice ": 99," CreateTime ":" 2017-14t21: 38: 26 "," DetailUrl ":" https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=App Share & utm # _campaign = t # _335139774 & utm # _term = qqfriends "," images ":" 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," Price ": 2999," PSCID ": 39," Sélectionné ": 0," Sellerid ": 1," Sous-idiot ":" HD Dual Camera, It Is Clear! "" 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 "," images ":" https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/ 59b857f2n6ca75622.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t9346/182/1406837243/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," Price ": 234," PSCID ": 39," Selected ": 0" La génération de l'iphone fait plus de scolarisation ":" 【【【iPhone Launch】 La génération de l'iphone de la smart de la Smart Différent "," titre ":" Apple iPhone 8 Plus (A1864) 64 Go Golden Mobile Unicom Telecom 4G Mobile "}]," Selnerme ":" Merchant 2 "," Sellerid ":" 2 "}, {" List ": [{" BargainPrice ": 111.99," CreateTime ":" 2017-10-03T23: 43: 53 "," DetailUrl ":" https://item.m.jd.com/product/4719303.html?utm_source= utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," images ":" https://m.360buyimg.com /n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1n9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/ N0 / JFS / T7504 / 338/63721388/491286 / F5957F53 / 598E95F1N7F2ADB87.JPG! Q70.JPG | HTTPS: //M.360BuyImg.com/N0 /jfs/t7441/10/64242474/419246/ADB30A7D/598E95FBND989BA0A.JPG!Q70.JPG" ,num":5 ,"pid":12,"price":256, "PSCID": 1, "Sélectionné": 0, "Sellerid": 5, "Sous-coussin": "Chaque festival de mi-automne ne peut pas être simple. Peu importe où vous êtes, vous avez toujours besoin d'un gâteau pour la livraison plus complète. Festival Mooncake Old Beijing Mooncake Box Box 655G "}]," sellname ":" Merchant 5 "," Sellerid ":" 5 "}, {" list ": [{" bar GainPrice ": 11800," CreateTime ":" 2017-10-03T23: 53: 28 "," DetailUrl ":" https://mitem.jd.hk/ware/view.act ion? wareid = 1988853309 & cachekey = 1ACB07A701ece8d2434a6ae7fa6870a1 "," images ":" 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!q70.jpg|https://m.360buyimg.com/n0 /jfs/t5815/178/2614671118/51656/7f52d137/593276c7n107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/j FS / T5878 / 60/2557817477 / 30873 / 4502B606 / 593276CAN5A7D6357.jpg! Q70.jpg "," num ": 1," PID ": 62," Price ": 15999," PSID ": 40," Sélectionné ": 0" Produits de bureau pour 1 yuan et retour aux billets de train pour 5 yuans (une fois le retour terminé) "," Title ":" Achat global de nouveaux modèles Apple MacBook Pro Apple ordinateur portable VP2 NOUVEAU BAR 13 pouces I5 / 8G / 256G "}]," Seldername ":" Merchant 6 "," Sellerid ":" 6 "}, {" list ": [{" Bargainprice ": 399," CreateTime ":" 2017-10-03t23: 53: 28 "," DetailUrl ":" https://item.m.jd.com/product/1439822107.html? UTM_SOURCE = AndroidApp & utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends " , "Images": "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!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/5737 4 / 5C73D281 / 59224C24N3324D5F4.jpg! Q70.jpg "," num ": 1," Pid ": 86," Price ": 777," PSCID ": 85, le prix total est de 65%", "Title": "GROP MENS," 2 pièces, le prix total est de 65%. Cinq sacs de pantalons droits jeans serrés 941825 Gris foncé 33/32 (175 / 84A) "}]," Selnername ":" Merchant 7 "," Sellerid ":" 7 "}, {" list ": [{" Bargainprice ": 111.99," CreateTime ":" 2017-14t21: 39: 05 "," DetailUrl ":" https://item.m.jd.com/prod UCT / 4719303.html? UTM_SOURCE = AndroidApp & utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," images ":" 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 ": 12," P ID ": 1," Prix ": 118," PSCID ": 1," Select ": 0," Sellerid ": 17," Sous-cuit ":" Chaque festival de mi-automne ne peut pas être simple. Daoxiangcun Mid-Automn Festival Mooncake Old Beijing Mooncake Gift Box 655G "}]," SelnerName ":" Merchant 17 "," Sellerid ":" 17 "}, {" list ": [{" Bargainprice " « .360buyimg.com / n0 / jfs / t9004 / 210/1160833155 / 647627 / AD6BE059 / 59B4F4E1N9A2B 1532.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t7504/338/63721388/491286 /f5957f53/598e95f1n7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t 7441 / 10/64242474/419246 / ADB30A7D / 598E95FBND989BA0A.JPG! Q70.JPG "," NUM ": 4, "Pid": 2, "Price": 299, "PSCID": 1, "Selected": 0, "Sellerid": 18, "Sous-the": "Chaque festival du milieu de l'automne ne peut pas être simple. Peu importe où vous êtes, vous avez toujours besoin d'un morceau de gâteau pour la livraison, plus surprenant, s'il vous plaît, met it avec votre doigt" Village de Daoxiang Daoxiang Village Mid-Automn Festival Festival Mooncake Old Beijing Mooncake Box Box 655G "}]," Seldername ":" Merchant 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," Price ": 37999.99," PSCID ": 40," Sélectionné ": 0," Sellerid ": 20," Sous-idire ":" Achetez des produits de bureau informatique pour 1 yuan et obtenez un coup d'achat de 5 yuan pour les titres de train (une fois que le return est à travers) " VP2 NOUVEAU BAR 13 pouces I5 / 8G / 256G "}]," SelnerName ":" Merchant 20 "," Sellerid ":" 20 "}, {" List ": [{" BargainPrice ": 111.99," CreateTime ":" 2017-14t21: 39: 05 "," DetailUrl ":" https://item.m.jd.com/product/4719303.html?utm_source=androida p & 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! E ": 88.99," PSCID ": 1," Sélectionné ": 0," Sellerid ": 21," Sous-cuit ":" Chaque festival de mi-automne ne peut pas être simple. Daoxiangcun Mid-Automn Festival Mooncake Old Beijing Mooncake Boad Box 655G "}]," Seldername ":" Merchant 21 "," Sellerid ":" 21 "}]] * / Private String Msg; code de chaîne privé; Données de liste privée <DataBean>; String public 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; } Dataean de classe statique publique {/ ** * Liste: [ot ium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," images ":" 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 / 56F0A09CN3E01BD0.JPG! Q70.JPG | HTTPS: //M.360BYIMG.C OM / N0 / JFS / T1882 / 31/2772215910 / 389956 / C8DBF370 / 56F0A0A2NA0C86EA6.JPG! Q70 .jpg | https: //m.360buyimg.com/n0/jfs/t2620/166/270383710/312660/531aa913 /57709035n33857877.jpg!q70.jpg" ,"num":1 ,"pid":24 ,"price":288 ,"pscid":2,"Selected":0 ,"sellerid":1,"subhead. It》 "," Title ":" Three Squirrel Nuts Rolated Snacks Creamy Pecan 225G / Bag "}, {" BargainPrice ": 11800," CreateTime ":" 2017-10-10t17: 33: 37 "," DetailUrl ":" https://item.m.jd.com/product/4338107. tml? utm # _source = AndroidApp & utm # _medium = appshare & utm # _campaign = t # _335139774 & utm # _term = qqfriends "," images ":" https://m.360buyimg.com/n0/jfs/t6700/ 155/2098998076/156185 / 6CF95035 / 595DD5A5NC3A7DAB5.JPG! Q70.JPG "," NUM ": 2," PID ": 57," Price ": 5199," PSCID ":" 40, "Selecte Mémoire vidéo MX150 2G] Mémoire de lunette 8G étroite Full HD 256 SSD prend en charge la reconnaissance digitale du système Win10 préinstallé "," Title ":" Xiaomi (MI) AIR 13.3 pouces Full Metal Thin Notebook (i5-7200U 8G 256G PCLE SSD MX150 2G Independent graphiques indépendants Fhd Recognition Win10) Fhd Fhd-Ringer-empreinte Win10)) Silver / r / n "}, {" BargainPrice ": 99," CreateTime ":" 2017-14t21: 38: 26 "," DetailUrl ":" https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=App Share & utm # _campaign = t # _335139774 & utm # _term = qqfriends "," images ":" 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," Price ": 2999," PSCID ": 39," Sélectionné ": 0," Sellerid ": 1," Sous-idiot ":" HD Dual Camera, It Is Clear! "," Title ":" OnePlus Mobile 5 (A5000) 6 Go + 64 Go Yueyanhui Network complet Connect Dual Sim Dual Sequy Mobile China Unicom Telecom 4G Mobile "}] * Seldername: Merchant 1 * Sellerid: 1 * / Private String sellname; STRACHE PRIVÉE VERLERID; Liste privée <SistBean> Liste; chèque booléen privé; public boolean ischeck () {return chèque; } public void setCheck (booléen check) {this.check = chèque; } public String getELLERNAME () {return sellName; } public void SetSeLername (String sellName) {this.sellername = sellName; } public String getSellerid () {return Sellerid; } public void SetSellerid (String Sellerid) {this.sellerid = Sellerid; } public List <SistBean> getList () {return list; } public void setList (list <s listBean> list) {this.list = list; } Classe statique publique 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=qqffriends * Images: https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fnbd3a1235.jpg!q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cn33e01bd0.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2na0c86ea6.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035n33857877.jpg! Q70.jpg * Num: 1 * PID: 24 * Prix: 288.0 * PSCID: 2 * Sélectionné: 0 * Sellerid: 1 * Sous-tiers: Trois collations d'écureuils Offre spéciale, 50 off pour les achats de plus de 99 dans la région, 100 réductions pour les achats de plus de 199 dans la région pygium 225g / bag à pygium 225g / bag * squirrel; Création de chaîne privée; DetailUrl de chaîne privée; images de chaîne privées; int privé int num; Int Pid privé; double prix privé; Int privé PSCID; private int sélectionné; private int Sellerid; Sous-tête de chaîne privée; titre de chaîne privée; Int privé COU = 1; public int getCou () {return cou; } public void setCou (int cou) {this.cou = cou; } chèque booléen privé; public boolean ischeck () {return chèque; } public void setCheck (booléen check) {this.check = chèque; } public double getBargainPrice () {return bargainprice; } public void setBargainPrice (double bargainprice) {this.bargainprice = bargainprice; } public String getCreateTime () {return CreateTime; } public void SetCreateTime (String CreateEtime) {this.createTime = CreateTime; } public String getDetailUrl () {return DetailUrl; } public void setDetailUrl (String DetailUrl) {this.detailUrl = DetailUrl; } public String getImages () {return images; } public void setimages (chaîne 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 () {prix de retour; } public void setPrice (double prix) {this.price = prix; } public int getpscid () {return pscid; } public void setpscid (int pscid) {this.pscid = pscid; } public int getSelected () {return sélectionné; } public void setSelected (int selected) {this.selected = selected; } public int getSellerid () {return Sellerid; } public void SetSellerid (int Sellerid) {this.sellerid = seleDid; } public String getSubhead () {return subhead; } public void setSubhead (String Subhead) {this.subhead = sous-ivale; } public String getTitle () {return title; } public void SettItle (String Title) {this.title = title; }}}} appliquer
La classe publique MyApp étend l'application {@Override public void onCreate () {super.Oncreate (); Fresco.Initialize (this); }} Voir la couche
Écrivez d'abord deux interfaces
Interface publique icart {void showlist (list <cartbean.dataBean> grouplist, list <list <cartbean.dataean.listbean >> childlist);} Interface publique iView <T> {void showbean (t t); void showstr (String S);}Disposition de la page principale
<? 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.bwie.zhangzhen20170108.MainActivity"> <poselistview Android_weight = "1" Android: Layout_Width = "wrap_content" Android: Layout_Height = "Wrap_Content" /> <linearlayout Android: Layout_Wight = "9" Android: orientation = "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 = "Sélectionner" Android: LAVE_WIDTH = "WINE_CONTENT" ANDRIOD: SHAPE_HEAUX) <Linearlayout Android: Layout_marginleft = "50DP" Android: orientation = "Vertical" Android: Layout_Width = "Wrap_Content" Android: Layout_height = "Wrap_Content"> <TextView Android: id = "@ + id / zongjia" Android: text = "Prix total: 0,0" /> <textView Android: text = "Total 0 items" Android: id = "@ + id / tv_count" Android: Layout_Width = "wrap_content" Android: Layout_Height = "Wrap_content" /> </ linearlayout> <TextView Android: Text = "Total Checkout" Android: Background = "#f820" Android: Layout_Marginleft = "100DP" Android: Layout_Width = "Wrap_Content" Android: Layout_Height = "Wrap_Content" /> </ linearlayout> </ linearlayout>
Page principale
La classe publique MainActivity étend AppCompatActivity implémente icart {private ExpandableListView Melv; Box à cocher privé Mquanxuan; Textview privé Mzongjia; TextView privé MTVCount; MyExpandableAdapter privé MyExpandableAdapter; @Override Protected void onCreate (bundle SavedInStanceState) {super.onCreate (SavedInStanceState); setContentView (r.layout.activity_main); initView (); Nouveau Cartpresenter (this) .getCart (); EventBus.getDefault (). Registre (this); mquanxuan.setOnClickListener (new View.OnClickListener () {@Override public void onClick (View v) {myExpandableAdapter.qx (mquanxuan.ischecked ());}}); } private void initView () {melv = (ExpandableListView) findViewByid (r.id.elv); mQuanxuan = (Checkbox) 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.dataean.listbean >> childlist) {myExpandableAdapter = new myExpandableAdapter (grouplist, this, childlist); melv.setAdapter (myExpandableAdapter); for (int i = 0; i <grouplist.size (); i ++) {melv.expandgroup (i); }} // Recevoir la valeur transmise @SubScriber public void onpriceAndCount (countandPrice cp) {mzongjia.setText ("total" + cp.getCount () + "item"); mtvCount.seTText ("Total:" + cp.getPrice ()); } // Recevoir la valeur transmise @Subscribe public void onPriceAndCount1 (événement MessgeEvent) {// Modifiez l'état sélectionné mQuanxuan.Setched (event.isCheck ()); } @Override Protected void onDestroy () {super.ondestroy (); EventBus.getDefault (). Unregister (this); }}La deuxième mise en page de page
<? xml version = "1.0" Encoding = "utf-8"?> <linearlayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tool Android: Layout_Height = "Match_parent" Android: orientation = "Vertical" Android: id = "@ + id / activité_add" Tools: context = "com.bwie.zhangzhen20170108.addactivity"> <com.facebook.drawee.view.simpledraweeView Android: Scelay Android: id = "@ + id / xqsdv1" Android: Layout_Gravity = "Center" Android: Layout_Height = "300DP" /> <TextView Android: id = "@ + id / tvtitle1" Android: Layout_Width = "Match_Parent" Android: LAYOUT_HEIGH Android: Layout_Width = "Match_parent" Android: Layout_Height = "Wrap_Content"> <Button Android: id = "@ + id / tiaozhuan1" Android: Layout_Weight = "1" Android: Text = "Jump to CART" Android: Layout_Width = "Match_parent" Android: Layout_Height = "WAVE_CONTENT" Android: id = "@ + id / tianjia1" Android: Layout_weight = "1" Android: text = "Add to CART" Android: Layout_Width = "Match_parent" Android: Layout_Height = "Wrap_Content" /> </ linearlayout> </ linearlayout>
Implémentation du code de panier
La classe publique AddActivity étend AppCompatActivity implémente View.OnClickListener, iView {private SimpledRaweeView MXQSDV; TextView privé mtvtitle; Button privé Mtiaozhuan; bouton privé Mtianjia; Maddactivité linéaire privée; Private XQPresenter XQPresenter; @Override Protected void onCreate (bundle SavedInStanceState) {super.onCreate (SavedInStanceState); setContentView (r.layout.activity_add); initView (); xqpresenter = new xqpresenter (this); xqpresenter.getxq (); } private void initView () {mxqsdv = (simpledRaweeView) findViewByid (r.id.xqsdv1); mtvtitle = (textView) findViewByid (r.id.tvtitle1); mtiaozhuan = (bouton) findViewByid (r.id.tiaozhuan1); mtiaozhuan.setOnClickListener (this); mtianjia = (bouton) findViewByid (r.id.tianjia1); mtianjia.setOnclickListener (this); maddActivity = (linearlayout) findViewByid (r.id.activity_add); } @Override public void onClick (View v) {switch (v.getId ()) {default: break; // Passez dans le cas de mainactivité (panier) R.ID.tiaozhuan1: startActivity (nouvelle intention (this, mainactivity.class)); casser; cas r.id.tianjia1: xqpresenter.getAdd (); casser; }} @Override public void showbean (objet 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; }} modèle
实现详情页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); } }); }}adaptateur
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 true; } /** * 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 true; } /** * 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>
Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.