Simpleadapter displays network images

Source: Internet
Author: User

The project displays a list of images and text, but the image cannot be displayed because simpleadapter does not directly support this type of data.

Explanation of Android. widget. simpleadapter. viewbinder In the API:

This class can be used by external clients of simpleadapter to bind values to views. You shocould use this class to views that are not directly supported by simpleadapter or to change the way binding occurs
For views supported by simpleadapter.

So do some processing on simpleadapter

Adapter. setviewbinder (New viewbinder () {public Boolean setviewvalue (view, object data, string textrepresentation) {// determine whether it is the object we want to process if (view instanceof imageview & Data instanceof Bitmap) {imageview IV = (imageview) view; IV. setimagebitmap (Bitmap) data); Return true;} else return false ;}});

Simpleadapter constructor: simpleadapter (context, list <? Extends Map <string,?> Data, int resource, string [] From, int [])
Data: the processed data item, such as arraylist Object>
Resource: used layout file from: the Key of the map object, such as new
String [] {"usename", "imgurl"}, to: component ID, such as new
Int [] {
R. id. text_view_user_name, R. id. image_view_icon}); A listview consists of multiple list items. Each list item is provided by a hashmap object, and multiple list items are provided by the arraylist object.

Related Article

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.