Android uses Simpleadapter to display bitmap images directly

Source: Internet
Author: User

In general, when using the Simpleadapter adapter, the picture resources that we want to display are local resources within the program, and are represented in the form of resource IDs.
Map.put ("img", r.drawable.i3);
But sometimes we need to use this adapter to display the remote picture on the Internet, how to display it directly? The method is to implement the Viewbinder () interface, which defines the matching relationship between the data and the view.

Adapter=NewSimpleadapter ( This, data,//Data SourceR.layout.activity_new_product_item,//Show Layout                NewString[] {"Itemimage", "Itemtext", "Itemnewprice", "Itemoldprice" },                 New int[] {r.id.itemimage, r.id.itemtext, R.id.newprice, r.id.oldprice}); Adapter.setviewbinder (NewViewbinder () {@Override Public Booleansetviewvalue (view view, Object data, String textrepresentation) {if(ViewinstanceofImageView) & (datainstanceofBitmap)) {ImageView IV=(ImageView) view; Bitmap BM=(Bitmap) data;                      Iv.setimagebitmap (BM); return true; }                      return false;        }        }); Gridview.setadapter (adapter);

Android uses Simpleadapter to display bitmap pictures directly

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.