protectedImageLoaderimageLoader;
privateImageViewimageView;
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// listView = (ListView) findViewById(R.id.listV);
// title = new String[]{
// "dd","ee",
// "dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee","dd","ee",
//
// };
//
// listView.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,title));
initImageLoader1(getApplicationContext());
imageView= (ImageView) findViewById(R.id.imageV);
}
/*
* 自定义配置
*/
public static voidinitImageLoader(Context context) {
ImageLoaderConfiguration.Builder config =newImageLoaderConfiguration.Builder(
context);
config.threadPoolSize(3);//线程池内加载的数量
config.threadPriority(Thread.NORM_PRIORITY-2);
config.denyCacheImageMultipleSizesInMemory();// 不缓存图片的多种尺寸在内存中
config.diskCacheFileNameGenerator(newMd5FileNameGenerator());// 将保存的时候的URI名称用MD5
config.diskCacheSize(50*1024*1024);// 50 MiB
config.tasksProcessingOrder(QueueProcessingType.LIFO);
config.writeDebugLogs();// Remove for release app
// 初始化ImageLoader
ImageLoader.getInstance().init(config.build());
}
/*
* 默认的配置,一般没有特殊的要求的时候就使用默认就好了。
*/
public static voidinitImageLoader1(Context context) {
// 创建默认的ImageLoader配置参数
ImageLoaderConfiguration configuration = ImageLoaderConfiguration
.createDefault(context);
// 初始化ImageLoader
ImageLoader.getInstance().init(configuration);
}
public voidloadIMA(View view){
ImageLoader.getInstance().displayImage("http://img2.imgtn.bdimg.com/it/u=3911179973,3770083939&fm=23&gp=0.jpg",imageView);// imageUrl代表图片的URL地址,imageView代表承载图片的IMAGEVIEW控件
}