Wemall App Store source to implement a ListView with a picture and checkbox

Source: Internet
Author: User

Wemall-mobile is based on the Wemall Android App Store, only need to upload the interface file in the original mall directory to complete the server configuration, the client can be customized modification. This article shares a ListView that implements a picture and a checkbox for technician reference.

Import Com.inuoer.util.asyncimageloader.imagecallback;import Com.inuoer.wemall.r;public class MainAdapter extends Baseadapter {private Layoutinflater minflater;//gets a Layoutinfalter object used to import the layout private arraylist<map<string, Object>> getdate;private Context Mcontext;public mainadapter (context context, arraylist<map<string, Object>> getDate) {this.mcontext = Context;this.minflater = Layoutinflater.from (context); this.getdate = GetDate;} @Overridepublic int GetCount () {//TODO auto-generated method Stubreturn getdate.size ();//Returns the length of the array} @Overridepublic Object getItem (int position) {//TODO auto-generated method Stubreturn getdate.get (position);} @Overridepublic long Getitemid (int position) {//TODO auto-generated method Stubreturn position;} @SuppressLint ("Newapi") @Overridepublic view GetView (final int position, view Convertview,viewgroup parent) {//TODO Auto-generated method stubfinal Viewholder holder;if (Convertview = null) {holder = new Viewholder (); Convertview = MINFLAter.inflate (r.layout.itemlist_shop, null); holder.image = (ImageView) Convertview.findviewbyid (r.id.itemlist_image ); holder.name = (TextView) Convertview.findviewbyid (r.id.itemlist_shopname); holder.price = (TextView) Convertview.findviewbyid (r.id.waimai_shopmenu_adapter_item_price); Holder.plusbutton = (ImageButton) Convertview.findviewbyid (r.id.plus_btn); Holder.minusbutton = (ImageButton) Convertview.findviewbyid (R.id.minus_ BTN); Holder.numtextview = (TextView) Convertview.findviewbyid (R.id.count); Convertview.settag (holder);// Bind Viewholder Object} else {holder = (Viewholder) convertview.gettag ();//Remove Viewholder object}convertview.setonclicklistener (  New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method stubfinal linearlayout layout = (linearlayout) minflater.inflate (r.layout.dialog_detail, NULL); final dialog Dialog = New dialog (Mcontext); Dialog.requestwindowfeature (Window.feature_no_title);d Ialog.setcontentview (layout);d ialog.show (); final ImageView ImageView = (ImageView) Layout.findviewbyid (r.id.dialog_detail_big_image); new Asyncimageloader (Mcontext). Downloadimage ( Getdate.get (position). Get ("image"). ToString (), True,new Imagecallback () {@Overridepublic void onimageloaded (Bitmap Bitmap, String imageUrl) {//TODO auto-generated method Stubimageview.setimagebitmap (bitmap);}}); TextView Textviewprice = (TextView) Layout.findviewbyid (R.id.dialog_detail_single_price); Textviewprice.settext ( Holder.price.getText (). toString ()); TextView textviewnum = (TextView) Layout.findviewbyid (R.id.count); Textviewnum.settext (Holder.numTextView.getText () . toString ()); Layout.findviewbyid (R.id.dialog_detail_close). Setonclicklistener (New Onclicklistener () {@ overridepublic void OnClick (View v) {//TODO auto-generated method Stubdialog.dismiss ();}); Layout.findviewbyid (R.id.dialog_detail_addcart). Setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method Stubdialog.dismiss ();}}); Final TextView Textviewin = (TextView) layout.fIndviewbyid (R.id.count); Layout.findviewbyid (R.ID.PLUS_BTN). Setonclicklistener (New Onclicklistener () {@ overridepublic void OnClick (View v) {//TODO auto-generated method Stubholder.plusButton.callOnClick (); Textviewin.settext (Holder.numTextView.getText (). toString ());}); Layout.findviewbyid (R.ID.MINUS_BTN). Setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) { TODO auto-generated Method Stubholder.minusButton.callOnClick (); Textviewin.settext (Holder.numTextView.getText () . toString ());});}); /string Imgurl = getdate.get (position). Get ("image"). toString ();//Asyncimageloader loader = new Asyncimageloader (MC Ontext)/////cache the picture to an external file//Loader.setcache2file (TRUE);//false////Set External cache folder//loader.setcached                Dir (Mcontext.getcachedir (). GetAbsolutePath ()); Download picture, whether the second parameter is cached in memory//Loader.downloadimage (Imgurl, False, new Asyncimageloader.imagecallback () {//@Override//publi c void onimageloaded (Bitmap Bitmap, String imageUrl{//if (bitmap! = null) {//holder.image.setimagebitmap (bitmap);//}else{////download failed, set default picture// Holder.image.setImageResource (R.drawable.about_logo);//}//}//}); new Asyncimageloader (Mcontext). Downloadimage ( Getdate.get (position). Get ("image"). ToString (), True,new Imagecallback () {@Overridepublic void onimageloaded (Bitmap Bitmap, String imageUrl) {//TODO auto-generated method Stubholder.image.setImageBitmap (bitmap);}}); Holder.name.setText (Getdate.get (position). Get ("name"). toString ()); Holder.price.setText (Getdate.get (position). Get ("price"). ToString ()); Holder.numTextView.setText (string.valueof (Cartdata.findcart (position)); Holder.plusButton.setOnClickListener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method Stubint num = Integer.parseint (Holder.numTextView.getText (). toString ()) + 1; Holder.numTextView.setText (string.valueof (num)); Cartdata.editcart (Getdate.get (position). Get ("id"). ToString (), getdate.get (position). Get ("name"). ToString (), Getdate.get (position). Get ("Price"). ToString (), string.valueof (num), getdate.get (position). Get ("image"). ToString ());}); Holder.minusButton.setOnClickListener (New Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method Stubint num = Integer.parseint (Holder.numTextView.getText (). toString ())-1;if (num >= 0) {Holde R.numtextview.settext (string.valueof (num)), if (num = = 0) {Cartdata.removecart (Getdate.get (position). Get ("id"). ToString ());} else {Cartdata.editcart (getdate.get (position). Get ("id"). ToString (), getdate.get (position). Get ("name"). ToString () , Getdate.get (position). Get ("price"). ToString (), string.valueof (num), getdate.get (position). Get ("image"). ToString ());}}}}); return Convertview;}}

  

Original Details Address: http://git.oschina.net/einsqing/wemall-mobile

Wemall-mobile Mall details Address: http://www.koahub.com/home/product/56

Wemall website Address: http://www.wemallshop.com

Wemall-Open Source Micro-Mall Mall Mall Source Distribution Mall B2B2C Mall system

Wemall App Store source to implement a ListView with a picture and checkbox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.