Android ImageLoader使用

首先须要,设置网络权限git

其次继承于Application的子类,做为加载的其实类,初始化ImageLoader的配置参数github

public class MyApplication extends Application {
   @Override
   public void onCreate() {
       // TODO Auto-generated method stub
       super.onCreate();
       ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
               getApplicationContext())
               .threadPriority(Thread.NORM_PRIORITY - 2)
               .denyCacheImageMultipleSizesInMemory()
               .discCacheFileNameGenerator(new Md5FileNameGenerator())
               .tasksProcessingOrder(QueueProcessingType.LIFO)
               .writeDebugLogs() // Remove for release app
               .build();
       ImageLoader.getInstance().init(config);
   }
}网络

从中能够看出ImageLoader是一个单例,所以使用是能够直接使用(参数初始化已经配置);app

简单实用异步

           ImageLoader.getInstance().displayImage(uri, p_w_picpathAware)
既能够异步加载图片ide

具体可参考github:https://github.com/nostra13/Android-Universal-Image-Loader
ui

相关文章
相关标签/搜索