Este artigo compartilha o código específico para a exibição de carrinho de compras de implementação do RXJAVA para sua referência. O conteúdo específico é o seguinte
Mostre a todos as renderizações primeiro
Estrutura da estrutura:
1. Estrutura do projeto: MVP, o carregamento da imagem é feito pelo Fresco, solicitações de rede são implementadas usando o Okhttp+Retrofit (Encapsulate você mesmo, adicione o modo Singleton),
2. Conclua a adição de dados do carrinho de compras (se não houver dados na interface, você poderá adicionar dados usando a ferramenta de interface).
3. Personalize a exibição para implementar o botão Adição e subtração. Cada vez que você clicar em Adicionar e subtrair, o número total e o preço total do item devem ser alterados de acordo.
4. Quando a quantidade for 1, clique no sinal de menos, a quantidade permanece inalterada e a torrada leva ao usuário que o número mínimo é 1.
5. O número total e o preço total na parte inferior são o preço total e o número total em todos os itens do item. Se o preço da quantidade em cada item for alterado, o número total do preço total na parte inferior deve estar vinculado a ele.
6. Implemente a função de seleção reversa de escolha única, digite a seleção padrão pela primeira vez, o número total e o preço total não estão incluídos nos dados inferiores quando o item não estiver selecionado. Quando o estado selecionado é alterado, o número total e o preço total da parte inferior podem ser modificados corretamente.
7. Clique no botão Excluir para excluir o item. O número total e o preço total na parte inferior podem ser modificados corretamente e os dados da interface serão excluídos.
Adicionar dependências necessárias e permissões de rede
compile 'com.squareup.retofit2: retrofit: 2.0.0-beta4' // retrofit2 Pacote necessário compile 'com.squareup.retrofit2: converter-gson: 2.0.0-beta4' // ConverterFactory's Gson dependência compilando 'com.squareup.retrofit2. Pacote de dependência da string compile 'io.reactivex.rxjava2: rxjava: 2.1.3'Compile' io.reactivex.rxjava2: rxandroid: 2.0.1'Compile 'com.squareUp.Retrofit2: adapter-rxjava2: 2.3..SquareUp.Rotofit2: adapter-rxjava2: 2.3.. 'De.GreenRobot: Eventbus: 3.0.0-beta1'compile' com.facebook.fresco: Fresco: 0.11.0 '
<usa-permission Android: name = "android.permission.internet" />
Subcontrato antes de usar o modo MVP
pacote de rede
API
classe pública API {public static string host = "http://120.27.23.105/product/";}ServiceApi
interface pública serveapi {@get ("getProductDetail") Flowable <XQBean> getxq (@query ("pid") int pid, @query ("origem") string str); @Get ("addCart") fluente <ditCart> getmsg (@query ("uid") int uid, @query ("pid") int pid, @query ("origem") string str); @Get ("getCarts") Flowable <ArtBean> getCart (@query ("uid") int uid, @query ("fonte") string str);}Interface bem -sucedida
interface pública onNetlisenter <T> {Void Success (t t);}Embalagem de adaptação
classe pública retrofithepler {public static okhttpclient okhttpclient; Public Static Serviceapi ServiceApi; / *** Execução prioritária*/ static {getOkhttpClient (); } public static okhttpclient getOkhttpClient () {if (okhttpclient == null) {synchronized (okhttpclient.class) {if (okhttpclient == null) {okhttpclient = new okhttpclient (); }} retornar okhttpclient; } public static serveapi getSerViCeapi () {if (serviceapi == null) {sincronizado (okhttpclient.class) {if (serveapi == null) {serviceapi = onCreate (serveapi.class, api.host); }}} retornar serviceapi; } public static <t> t onCreate (classe <T> tclass, string url) {retrofit retrofit = new Retrofit.builder () .baseurl (url) .addConverterFactory (gsonConverterFactory.create () .client (okhttpClient) .AddClalladActerFactory () .cliCent.Client2Client2CliTornAcTerFactory (). //. AddCallAdapterFactory (rxjava2CallAdapterFactory.Create ()) .Build (); return return.create (tclass); }} pacote de feijão
Página de aula de feijão para detalhes
public class XQBean { /** * msg : * seller : {"description":"I am a merchant 2","icon":"http://120.27.23.105/images/icon.png","name":"merchant 2","productNums":999,"score":5,"sellerid":2} * code : 0 * data : {"BargainPrice": 111.99, "CreateTime": "2017-10-14T21: 48: 08", "detalheurl": "https://item.m.jd.com/product/4719303.html?utm_source=androidTeareee 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,"subhead":"Every Mid-Autumn Festival cannot be simple. No matter where you are, you always need a piece of cake to make your life more complete, JD Mooncake makes love more complete, JD Self-operated, Lightning delivery, more surprises, poke with your Dedos "," Title ":" Pequim Daoxiangcun Daoxiangcun Festival no meio do outono MoonCake Old Pequim BoonCake Gift Box 655G "} */ String privada msg; vendedor de vendedores particulares; Código de string privado; dados de banco de dados privados; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } Public SellerBean getSeller () {Return Seller; } public void SetSeller (SellerBean Seller) {this.seller = Seller; } public String getCode () {Return Code; } public void setCode (código da string) {this.code = code; } Public Databean getData () {retornar dados; } public void setData (dados do banco de dados) {this.data = data; } classe estática pública SellerBean {/** * Descrição: Eu sou um comerciante 2 * Icon: http://120.27.23.105/images/icon.png * Nome: Merchant 2 * ProductNums: 999 * Pontuação: 5.0 * SellerID: 2 */Private String Descrição; Ícone de String Private; nome de string privado; Produto Int ProductNums; Pontuação dupla privada; Private Int SellerID; public string getDescription () {return description; } public void SetDescription (String description) {this.Description = Descrição; } public string geticon () {return icon; } public void Seticon (Ícone da String) {this.icon = icon; } public string getName () {return name; } public void setName (nome da string) {this.name = name; } public int getProductNums () {return productNums; } public void setProductNums (int productNums) {this.productnums = productNums; } public Double getScore () {Return Score; } public void setScore (pontuação dupla) {this.score = score; } public int getSelerid () {return selllerID; } public void setSellerId (int sellerID) {this.sellerid = SellerID; }} Databean da classe estática pública { /** * BARGAINPRICE: 111.99 * CreateTime: 2017-10-14T21: 48: 08 * detalheurl: https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=qqfriends * imagens: imagens: imagens: 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 * Preço: 78.99 * PSCID: 1 * VENDAS: 2356 * SellerID: 2 * subtítulo: Todo festival no meio do outono não pode ser simples. Não importa onde você esteja, você sempre precisa de um pedaço de bolo para tornar sua vida mais completa. JD MoonCakes Torne o amor mais completo JD auto-operado, entrega de raios, mais surpresas, clique com o seu dedo * Título: Pequim Daoxiangcun Daoxiangcun Festival do Meio-Autumn Festival Mooncake Antigo Beijing MoonCake Box Caixa de presente 655g */ Pedido duplo privado; String privada CreateTime; Private String detalheurl; imagens de string privada; Private Int ItemType; private int pid; preço duplo privado; private int pscid; private Int Salesenum; Private Int SellerID; Subpice de String Private; título de sequência privada; public Double getBarGainPrice () {return bargainprice; } public void setBarGainPrice (duplo bargainprice) {this.BarGainPrice = bargainprice; } public string getCreateTime () {return createTime; } public void setCreateTime (string createTime) {this.createTime = createTime; } public string getDetailurl () {return detalheturl; } public void setDetailurl (string detalheurl) {this.detailurl = detalheurl; } public string getImages () {return Images; } public void setImages (string imagens) {this.images = imagens; } 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 (preço duplo) {this.price = price; } public int getpscid () {return pscid; } public void setpscid (int pScid) {this.pscid = pscid; } public int getSalenum () {return salesenum; } public void SetsalEnum (int vendasenum) {this.salenum = salesenum; } public int getSelerid () {return selllerID; } public void setSellerId (int sellerID) {this.sellerid = SellerID; } public string getsubhead () {return subthhop; } public void setSubhead (String subthead) {this.subhead = subthepta; } public string gettitle () {return título; } public void Settitle (título da string) {this.title = title; }}}Bean adicionado ao carrinho
classe pública addcart {private string msg; Código de string privado; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } public String getCode () {Return Code; } public void setCode (código da string) {this.code = code; }}Categoria de produto
classe pública CartBean { /*** msg: solicitar bem -sucedido* código: 0* dados: [{"List": [{"bargainprice": 22.9, "CreateTime": "2017-10-14T21: 48: 08", "detalheurl": "https://item.m.jd.com/product/2542855.html & utm_medium = AppShare & utm_campaign = t_335139774 & utm_term = qqfriends "," imagens ":" https://m.360buyimg.com/n0/jfs/t1930/284/2865662920/3930/52430/56562962920/3930/52430/ade de 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 ! 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 》","title":"Three Squirrel Nuts Roasted 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," Price ": 5199," PSCID ": 40," Selected ": 0," SellerID ": 1," Subider ":" 【I5 Memória de vídeo MX150 2G] Full HD MEMAIS DE MECIMENTO DE 8G DE FULLETA 256 SSD suporta reconhecimento de impressões digitais Pré-instalado Sistema Win10 "," Title ":" Xiaomi (Mi) AIR 13,3 polegadas Metal Full ToilBobook (I5-7200U 8G 256G PCLE SSD MX150 2G 2G IndependentPhics FHHD Plicms prata/r/n "}, {" bargainprice ": 99," CreateTime ":" 2017-10-14T21: 38: 26 "," detalheurl ":" https://item.m.jd.com/product/4345173.htmml?utm#_source=androidReids compartilhar & utm#_campaign = t#_335139774 & utm#_term = qqfriends "," imagens ":" 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! Monster! 1 "," SellerID ":" 1 "}, {" List ": [{" BargainPrice ": 6666," CreateTime ":" 2017-10-10T16: 01: 31 "," detalheurl ":" https://item.m.jd.com/product/5089273 .html? utm#_source = AndroidApp & utm#_medium = appshare & utm#_campaign = t#_335139774 & utm#_term = Qqfriends "," imagens ":" 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,"sellerid":2,"subhead":"【New iPhone launch】The new generation of iPhone makes the smart look more diferente "," title ":" Apple iPhone 8 Plus (A1864) 64 GB Golden Mobile Unicom Telecom 4G Mobile "}]," SellerName ":" Merchant 2 "," SellerID ":" 2 "}, {" List ": [{" bargainprice ": 111.99," CreateTime ":" 2017-10-03T23: 43: 53 "," detalheurl ":" https://item.m.jd.com/product/471930 ": utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," imagens ":" 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, furos, "PSCID": 1, "Selected": 0, "Sellerid": 5, "subthead": "Todo festival no meio do outono não pode ser simples. Não importa onde você esteja, você sempre precisa de um bolo para tornar sua vida mais completa. JD MoonCakes torna o amor mais completo. MooCake Old Pequim Caixa de Presente da Mooncake 655G "}]," SellerName ":" Merchant 5 "," SellerID ":" 5 "}, {" List ": [{" Bar GainPrice ": 11800," CreateTime ":" 2017-10-03T23: 53: 28 "," detalheurl ":" 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,"pscid":40,"selected":0,"sellerid":6,"subhead":"Purchase some computer Produtos de escritório para 1 yuan e retorne para treinar ingressos para 5 yuan (quando o retorno terminar) "," Title ":" Compra global dos novos modelos Apple MacBook Pro Apple Laptop Silver VP2 Novo barra de 13 polegadas I5/8g/256g "}]," SellName ":" Merchant 6 "," SellerID ":" 6 "}, {" List ": [{" BargainPrice ": 399," CreateTime ":" 2017-10-03T23: 53: 28 "," detalheurl ":" https://item.m.jd.com/product/143982107 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! /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,"selected":0,"sellerid":7,"subhead":"2 pieces, total price is 65% off","title":"Gap men's casual, Lavagem confortável e simples cinco sacos de calças retas jeans apertadas 941825 cinza escuro 33/32 (175/84a) "}]," SellerName ":" Merchant 7 "," SellerID ":" 7 "}, {" List ": [{" bargainprice ": 111.99," CreateTime ":" 2017-10-14T21: 39: 05 "," detalheurl ":" https://item.m.jd.com/prod uct/4719303.html? utm_source = Androidapp & utm_medium = AppShare & utm_campaign = t_335139774 & utm_term = QQFriends "," imagens ":" 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," Preço ": 118," PSCID ": 1," Selecionado ": 0," SellerID ": 17," subtítulo ":" Todo festival do meio do outono não pode ser simples. Daoxiangcun Festival no meio do festival Mooncake Old Beijing Mooncake Box Box 655G "}]," SellerName ":" Merchant 17 "," SellerID ":" 17 "}, {" List ": [{" BARGAINPRICE ": 111.99," CreateTime ":" 2017-14-14-14-14 "": 111.99. : //item.m.jd.com/product/4719303.html? utm_source = Androidapp & utm_medium = AppShare & utm_campaign = t_335139774 & utm_term = QQFriends "," imagens ":" https: // .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,"subhead":"Every Mid-Autumn Festival cannot be simple. No matter where you are, you always need a piece of cake to make your life more complete, JD mooncakes make love more complete, JD self-operated, lightning delivery, more surprises, please poke it with your finger","title":"Beijing Daoxiang Village Daoxiang Village Mid-Urbumm Festival MoonCake Old Pequim Lua Mooncake Box 655G "}]," SellerName ":" Merchant 18 "," SellerID ":" 18 "}, {" List ": [{" bargainprice ": 11800," createTime ":" 2017-10-03T23: 53: 28 "," detalheurl ":" 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! 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,"selected":0,"sellerid":20,"subhead":"Purchase some computer office products for 1 yuan and get a 5 yuan coupon for train tickets (once the return is over)","title":"Global purchase of new Apple MacBook Pro Apple laptop silver VP2 Novo Bar I5/8g/256g "}]," SellerName ":" Merchant 20 "," Sellerid ":" 20 "}, {" LIST ": [{" bargainprice ": 111.99," CreateTime ":" 2017-10-14T21: 39: 05 "," Detainurl ":" https://item.m.jd.com/product/47193.htps://item.jd.com/product/471930 " p & utm_medium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," imagens ":" 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," Selecionado ": 0," Sellerid ": 21," Subthe ":" Todo festival do meio do outono não pode ser simples. Festival do Mid-Utumn do Daoxiangcun MoonCake Old Pequim BoonCake Box Box 655G "}]," SellerName ":" Merchant 21 "," SellerID ":" 21 "}]] */ msg de sequência privada; Código de string privado; Lista privada <dAdean> dados; public String getMsg () {return msg; } public void setmsg (string msg) {this.msg = msg; } public String getCode () {Return Code; } public void setCode (código da string) {this.code = code; } list public <dABean> getData () {retornar dados; } public void setData (list <dAbean> data) {this.data = data; } Batida de classe estática pública { /*** Lista: [{"BARGAINPRICE": 22.9, "CreateTime": "2017-10-14T21: 48: 08", "detalheurl": "https://item.m.jd.com/product/2542855.html?utm_source=andappApp&2542855 ium = appshare & utm_campaign = t_335139774 & utm_term = qqfriends "," Images ":" https://m.360buyimg.com/n0/jfs/t1930/284/28629620/390243ade3/1930/284/286629620/390243. fnbd3a1235.jpg! Q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/2802996 626/155915/E5E90D7A/56F0A09CN33E01BD0.JPG! Q70.JPG | https: //m.360buyimg.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":"Three Squirrels snack special offer, 50 off for the area over 99, 100 off for the purchase over 199, hurry up and buy it》", "title":"Three Squirrel Nuts Roasted Snacks Creamy Pecan 225g/bag"},{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.h 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,"selected":0,"sellerid":1,"subhead":"【i5 Memória de vídeo MX150 2G] Full HD MEMAIS DE MECIMENTO DE 8G DE FULLETA 256 SSD suporta reconhecimento de impressões digitais Pré-instalado Sistema Win10 "," Title ":" Xiaomi (Mi) AIR 13,3 polegadas Metal Full ToilBobook (I5-7200U 8G 256G PCLE SSD MX150 2G 2G IndependentPhics FHHD Plicms prata/r/n "}, {" bargainprice ": 99," CreateTime ":" 2017-10-14T21: 38: 26 "," detalheurl ":" https://item.m.jd.com/product/4345173.htmml?utm#_source=androidReids compartilhar & utm#_campaign = t#_335139774 & utm#_term = qqfriends "," imagens ":" 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! Monster! private String SellerID; Lista privada <ListBean> Lista; Verificação booleana privada; public boolean ischeck () {return check; } public void SetCheck (checagem booleana) {this.check = 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; } list public <listbean> getList () {Lista de retorno; } public void setList (list <listbean> list) {this.list = list; } classe estática pública listBean { /** * BargainPrice: 22.9 * CreateTime: 2017-10-14T21: 48: 08 * detalheurl: https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=qqfriends * imagens: imagens: https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fnbd3a1235.jpg!q70.jpg | https: //m.360buyimg.com/n0/jfs/t2137/336/28029966626/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 * Preço: 288.0 * PSCID: 2 * Selecionado: 0 * SellerID: 1 * subpoft: Três lanches de esquilo Oferta especial, 50 de folga para compras acima de 99 na área, 100 flaveres de creamy de pecuares; String privada CreateTime; Private String detalheurl; imagens de string privada; privado int num; private int pid; preço duplo privado; private int pscid; privado int selecionado; Private Int SellerID; Subpice de String Private; título de sequência privada; private int cou = 1; public int getCou () {return cou; } public void setCou (int cou) {this.cou = cou; } verificação booleana privada; public boolean ischeck () {return check; } public void SetCheck (checagem booleana) {this.check = check; } public duplo getBarGainPrice () {return bargainprice; } public void setBarGainPrice (duplo bargainprice) {this.BarGainPrice = bargainprice; } public string getCreateTime () {return createTime; } public void setCreateTime (string createTime) {this.createTime = createTime; } public string getDetailurl () {return detalheturl; } public void setDetailurl (string detalheurl) {this.detailurl = detalheurl; } public string getImages () {return Images; } public void setImages (string imagens) {this.images = imagens; } 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 (preço duplo) {this.price = price; } public int getpscid () {return pscid; } public void setpscid (int pScid) {this.pscid = pscid; } public int getSelected () {return Selected; } public void setSelected (int selecionado) {this.Selected = selected; } public int getSelerid () {return selllerID; } public void setSellerId (int sellerID) {this.sellerid = SellerID; } public string getsubhead () {return subthhop; } public void setSubhead (String subthead) {this.subhead = subthepta; } public string gettitle () {return título; } public void Settitle (título da string) {this.title = title; }}}} App
public class MyApp estende o aplicativo {@Override public void onCreate () {super.oCreate (); Fresco.initialize (isto); }} Visualizar camada
Escreva duas interfaces primeiro
interface pública Icart {void showlist (list <CartBean.databean> grouplist, list <list <CartBean.databean.listbean >> Childlist);} interface pública IView <t> {void showbean (t t); void shows (strings);}Layout da página principal
<? xml versão = "1.0" coding = "utf-8"?> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: app = http:/schema.android " xmlns: ferramentas = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: Layout_Height = "Match_Parent" Android: Orientation = "Vertical" Ferramentas: Context = "comin.bwie.zhangzhen20170) Android: id = "@+id /elv" Android: layout_weight = "1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" /> <linearLayout Android: layout_weight = "9" Andro_ " Android: Layout_Height = "Match_Parent"> <Caixa de seleção Android: id = "@+id /quanxuan" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" /> <TextView Android: text = "Select All" Android: Android: Android: Layout_Height = "WRAP_CONTENT" /> <LinearLayout Android: Layout_Marginleft = "50dp" Android: Orientation = "Vertical" Android: Layout_width = "WRAP_CONTENT" Android: Layout_Height = "Wrap_Content 4-VIGHTRONVIGHRONGRANTEN e Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: text = "Preço total: 0,0" /> <TextView Android: text = "Total 0 itens" Android: id = "@+id /tv_count" Android: layout_width " Android: layout_height = "wrap_content" /> < /linearlayout> <textView Android: text = "Total checkout" Android: Background = "#ffd82020" Android: Layout_MarginLeft "Android: Layout_width =" WR_PR_CONTENTE </linearlayout> </leinearlayout>
Página principal
A classe pública MainActivity estende o appCompatactivity implementa o ICART {private expandableListView Melv; Caixa de seleção privada Mquanxuan; Principal de texto privado Mzongjia; Private TextView MTVCount; Privado MyExpandableAdApter MyExpandableAdApter; @Override Protected void onCreate (pacote savedInstancestate) {super.oCreate (savedInstancestate); setContentView (r.layout.activity_main); initView (); novo CartPresenter (this) .getCart (); Eventbus.getDefault (). Register (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 = (caixa de seleção) 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) {myexpandableAdApter = new MyexpandablaadApter (grouplist, este, infantil); melv.setAdapter (myExpandableAdApter); for (int i = 0; i <grouplist.size (); i ++) {melv.expandgroup (i); }} // Receba o valor transmitido @subscribe public void onpriceAndCount (counthandprice cp) {mzongjia.settext ("total"+cp.getCount ()+"item"); mtvcount.settext ("Total:"+cp.getprice ()); } // Receba o valor transmitido @subScribe public void onpriceAndCount1 (Evento MessgeEvent) {// Altere o estado selecionado Mquanxuan.Setchecked (Event.ischeck ()); } @Override Protected void OnDestroy () {super.ondestroy (); Eventbus.getDefault (). Ungistister (this); }}O layout da segunda página
<? xml versão = "1.0" coding = "utf-8"?> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: ferramentas = "http://schem.android.com/ont.com/onts" e " android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/activity_add" tools:context="com.bwie.zhangzhen20170108.AddActivity"> <com.facebook.drawee.view.SimpleDraweeView android:layout_width="300dp" Android: id = "@+id /xqsdv1" Android: layout_gravity = "Center" Android: layout_height = "300dp" /> <textView Android: id = "@+id /tvTitle1" Android: layout_width = "Match_Parent" Android: Layout_Height1 " Android: Orientation = "Horizontal" Android: layout_width = "match_parent" Android: layout_height = "wrap_content"> <button Android: id = "@+id/tiaozhuan1" Android: Layout_weight = "1" Andro: text = "Cart Android: layout_height = "wrap_content"/> <botão Android: id = "@+id/tianjia1" Android: layout_weight = "1" Android: text = "Adicione ao carrinho" Android: Layout_width = "Match_Parent" Android: Layout_Haight = WRAPS:
Implementando o código do carrinho de compras
classe pública AddActivity estende AppCompatactivity implementa View.OnClickListener, IView {private SimpleDraweeview MXQSDV; Private TextView mtvtitle; botão privado mtiaozhuan; Button privado Mtianjia; MaddActivity privado linearlayout; XQPRESTER privado XQPRESTER; @Override Protected void onCreate (pacote savedInstancestate) {super.oCreate (savedInstancestate); setContentView (r.layout.activity_add); initView (); xqpresenter = new XQPrender (this); xqpResenter.getxq (); } private void initView () {mxqsdv = (simpledraweeview) findViewById (r.id.xqsdv1); mtvtitle = (TextView) findViewById (r.id.tvtitle1); mtiaozhuan = (botão) findViewById (r.id.tiaozhuan1); mtiaozhuan.setOnClickListener (isto); mtianjia = (botão) findViewById (r.id.tianjia1); mtianjia.setOnClickListener (isto); maddactivity = (linearlayout) findviewById (r.id.activity_add); } @Override public void OnClick (view v) {switch (v.getId ()) {padrão: break; // Pule para a MainActivity (carrinho de compras) case R.id.tiaozhuan1: startActivity (nova intenção (this, mainActivity.class)); quebrar; case r.id.tianjia1: xqpresenter.getAdd (); quebrar; }} @Override public void showbean (objeto o) {xqbean xqbean = (xqbean) o; Xqbean.databean dados = xqbean.getData (); String s = data.getImages (). Split ("// |") [0]; URI URI = URI.PARSE (S); // Endereço convertido em 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 (); }} Pacote Eventbus
Defina uma classe de quantidade e preço
classe pública CountAndPrice {private int count; Price Private Int; public int getCount () {Return Count; } public void setCount (int conting) {this.count = count; } public int getPrice () {Return Price; } public void SetPrice (int price) {this.price = price; }}Eventbus
classe pública MessgeEvent {Private Boolean Check; public boolean ischeck () {return check; } public void SetCheck (checagem booleana) {this.check = check; }} modelo
Implemente a interface da camada modelo da página de detalhes
interface pública ixqmodel {public void getxq (int pid, string str, final onNetlisenter <xqbean> cgsb);}Implementar o modelo de página de detalhes
classe pública xqmodel implementa ixqmodel {@Override public void getxq (int pid, string str, final onNetlisenter <XQBean> onNetlisenter) {fluxo <xqQBean> flowable = retrofithepler.getServicapi (). getXq (Pid, Sst); Flowable.Observeon (Androidschedulers.Mainthread ()) .SubScribe (schedulers.io ()) .SubScribe (novo consumidor <XQBean> () {@Override Public void (xQBean XQBean) Throws Exception {OnNetLisEr.Success (XQBean); } public void getAdd (int uid, int pid, string str, final onNetlisenter <DDDCART> onNetlisenter) {Flowable <DitDCART> Flowable = retrofithEpler.getServiceApi (). getmsg (uid, pid, str); Flowable.observeon (Androidschedulers.Mainthread ()) .SubScribe (schedulers.io ()) .SubScribe (novo consumidor <DDDCART> () {@Override public void (addcart); }}Modelo de carrinho de compras
classe pública CartModel {public void getCart (int uid, string str, final onNetlisenter <ArtBean> onNetlisenter) {Flowable <ArtBean> Flowable = retrofithepler.getServiceApi (). getcart (uid, str); Flowable.observeon (Androidschedulers.Mainthread ()) .SubScribe (schedulers.io ()) .SubScribe (novo consumidor <TartBean> () {@Override public void (CartBean CartBean) lança excepção {onNetLisEnter.success (CartBean); }} camada de apresentador
Camada p da página de detalhes
classe pública 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", novo onNetlisenter <XQBean> () {@Override public void sucem (xqbean xqbean) {iview.showbean (xqbean);}}); } public void getadd () {xqmodel.getAdd (3043, 12, "Android", novo onNetlisenter <DDECTCART> () {@Override public void sucem (addCart addcart) {iview.showstr (addcart.getmsg ()); }}Nível P do carrinho de compras
classe pública 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 <ArtBean> () {@Override public void sucel (cartbean cartBean) {list <tetBean.databean> Grouplist = cartBean.getData (List ListAltB (ListBean. Arraylist <> () para (int i = 0; i <grouplist.size (); }); }}adaptador
classe pública myexpandabableAdApter estende BasexpandableListAdapter {Private List <CartBean.databean> GroupData; contexto privado de contexto; Lista privada <LIST <CARTBEAN.DATABEAN.LISTBEAN >> ChildList; public myExpandableAdApter (list <CartBean.databean> groupData, contexto de contexto, 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 (GROUPPOSIÇÃO) .SIZE (); } @Override Public Object getGroup (int groupPospo) {return groupData.get (GroupPposition); } @Override Public Object getChild (int groupPosition, int position) {return null; } @Override public Long GetGroupId (int groupPospo) {return GroupPospo; } @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>
O exposto acima é todo o conteúdo deste artigo. Espero que seja útil para o aprendizado de todos e espero que todos apoiem mais o wulin.com.