Android-universal-image-loader Loading Pictures

Source: Internet
Author: User

Look directly at the code: mainactivity:

Package Com.example.textwsjdemo;import Com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; Import Com.nostra13.universalimageloader.core.displayimageoptions;import Com.nostra13.universalimageloader.core.imageloader;import Com.nostra13.universalimageloader.core.imageloaderconfiguration;import Com.nostra13.universalimageloader.core.assist.queueprocessingtype;import Com.nostra13.universalimageloader.core.display.roundedbitmapdisplayer;import Android.app.Activity;import Android.os.bundle;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.Button; Import Android.widget.imageview;public class Mainactivity extends Activity {private String url;private Button bt_hehe; Private ImageView iv_photo;private displayimageoptions defaultoptions;private imageloaderconfiguration config;@        Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main);        Initview ();              Defaultoptions = new Displayimageoptions.builder (). Showstubimage (R.drawable.ic_launcher)//load start default picture . Showimageforemptyuri (R.drawable.ic_launcher)//url to show the picture and put it in the drawable. Showimageonfail (r.drawable        . Ic_launcher)//The picture is displayed when there is a problem loading the picture. Cacheinmemory (True)//cache is not cached with Fslae. Cacheondisc (TRUE)//cache                . Displayer (New Roundedbitmapdisplayer (5))//Picture fillet display with a value of integer. Build ();        Config = new Imageloaderconfiguration.builder (mainactivity.this). Defaultdisplayimageoptions (DefaultOptions) . ThreadPriority (Thread.norm_priority-2). Denycacheimagemultiplesizesinmemory (). Disccachefilenamegenerato R (New Md5filenamegenerator ()). Tasksprocessingorder (QUEUEPROCESSINGTYPE.LIFO)//. EnableLogging ()/Not nece        Ssary in common. Build ();                    Imageloader.getinstance (). init (config); }private void Initview () {//Picture URlurl = "Http://file.koolearn.com/20131018/1382077932449.jpg"; bt_hehe = (Button) Findviewbyid (r.id.bt_hehe); iv_ Photo = (ImageView) Findviewbyid (R.id.iv_photo); Bt_hehe.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated Method Stubimageloader.getinstance (). DisplayImage (Url,iv_photo, Defaultoptions);    URL as picture address, Iv_photo for ImageView Layout,}});} }

This code can be implemented to load the network picture, import Image-loader jar package can be

Image-loader Download: Https://github.com/nostra13/Android-Universal-Image-Loader


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android-universal-image-loader Loading Pictures

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.