"The speed of light using open source frame series" Picture loading frame Imageloader

Source: Internet
Author: User

"About this series"

Recently saw a lot of open source framework, online information is also very much, but I think the best way to understand a framework is actually used. This series of blog is to lead you to quickly get started with some common open source framework, experience its role.

Due to the limited author level, this series will only describe how to quickly use the basic functions of the framework, and more detailed settings can be found on the pages of these items.

"Introduction":

As an open-source asynchronous Picture loading framework, Imageloader is often used in Android development, which can load and display pictures. and caching it provides a number of handy options to help developers quickly reach their development needs.

"GitHub page":

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

"Use steps"

1. Download the zip package from the project page or clone to the local, find the jar package, import your own project, about how to import, depending on the use of the IDE is also slightly different, you can search by themselves

2. Create an activity

3. Create a new Imageloaderconfiguration object for Imageloader initialization, which can be directly called by the default method, as follows

4. Initialize the Imageloader object, since the use of singleton mode, so the initialization can be

5. Create a Displayimageoptions object that can set options for displaying pictures, such as whether to cache locally, cache to memory, display what is displayed when it fails, etc.

6. Call Imageloader's displayimage (String uri, ImageView ImageView, displayimageoptions options) method to display.

Code

 Public classMainactivityextendsActivity {displayimageoptions Options;//option class can do some setup @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); ImageView ImageView=(ImageView) Findviewbyid (r.id.iv_1);//Instantiate ImageView String imageUrl= "Https://www.baidu.com/img/bdlogo.png";//Set Picture URL imageloaderconfiguration config= Imageloaderconfiguration.createdefault ( This);//Initialize the Config class for initializing imageloader.getinstance (). init (config);//Initialize loader options=NewDisplayimageoptions.builder (). Cacheinmemory (true)//Whether the memory is cached. Cacheondisk (true)//Whether it is cached to disk. Bitmapconfig (Bitmap.Config.RGB_565)//Configuration picture is displayed in how to encode. Showimageonfail (r.drawabl        E.PIC2)//Set local Picture resource to display when unable to load. Build (); Imageloader.getinstance (). DisplayImage (Imageurl,imageview, options);//Call displayimage function, display}}

【】

As you can see, our picture has been successfully loaded.

"A more complex example, combined with a ListView or Viewpager"

Please refer to here:

Http://www.cnblogs.com/tianzhijiexian/p/4034386.html

"The speed of light using open source frame series" Picture loading frame Imageloader

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.