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 to start the default picture . Showimageforemptyuri (R.drawable.ic_launcher)//url displays the picture as empty. Put yourself in the drawable. Showimageonfail (R.drawable.ic_launcher)//Loading picture fails, the picture is displayed. Cacheinmemory (TRUE)//cache Fslae does not cache. Cacheondisc (TRUE)//cache with. Displayer (new Roundedbitmapdisplayer (5))//Picture fillet display with a value of integer. b Uild (); 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. Importing the Image-loader jar package will
Image-loader Download: Https://github.com/nostra13/Android-Universal-Image-Loader
Android-universal-image-loader Loading Pictures