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