"Reprint" A line of code load Network pictures to imageview--android Picasso

Source: Internet
Author: User

text link : A code load network pictures to imageview--android Picasso

Introduce an android framework here: Picasso.

Picasso is an open source Android graphics cache Library at square, address http://square.github.io/picasso/, which allows for image download and caching capabilities. Just one line of code is required to fully implement the asynchronous loading of the image. The code is as follows:

 Public classMainactivityextendsActivity {PrivateImageView ImageView; PrivateString url= "Http://h.hiphotos.baidu.com/image/pic/item/64380cd7912397dd6e6c3adf5c82b2b7d1a287d0.jpg"; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);          Setcontentview (R.layout.activity_main); ImageView=(ImageView) Findviewbyid (R.id.testimageid); Picasso.with (  This ). Load (URL). into (ImageView); }}

The key line of code:

Picasso.with (this). Load (URL). into (ImageView);  

In the test, you still need to be in Androidmanifest.xml plus access to network permissions.

<android:name= "Android.permission.INTERNET"/>

"Reprint" A line of code load Network pictures to imageview--android Picasso

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.