Android asynchronous download of images

Source: Internet
Author: User

For Android apps, there are several ways to download images from the Internet:

1,

2. Use aquery

Simple:

AQ. ID (R. Id. image1). Image ("http ://...")

Cache Control

Boolean memcache = false;

Boolean filecache = true;

AQ. ID (R. Id. image1). Image ("http: //...", memcache, filecache );

Down sampling

AQ. ID (R. Id. image1). Image (imageurl, true, true, 200,0)

Fallback Image

// If we are not able to load the image, use a default image

AQ. ID (R. Id. image1). Image (imageurl, true, true, 200,0, R. drawable. default_image)

Preloading

SS

    

String imageUrl = "http://farm6.static.flickr.com/5035/5802797131_a729dac808_b.jpg";aq.id(R.id.image).progress(R.id.progress).image(imageUrl, false, false);

Sample grid item layout:

<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "100dip"> <progressbar Android: layout_width = "15dip" Android: layout_height = "15dip" Android: Id = "@ + ID/progress" Android: layout_centerinparent = "true"/> <imageview Android: Id = "@ + ID/image" Android: layout_width = "fill_parent" Android: layout_height = "75dip"/> </relativelayout>

And so on,

Web: http://code.google.com/p/android-query/wiki/ImageLoading

Android sometimes has nothing to do with logcat. Click ddms and it will be OK.

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.