[android]代码库
package com.example.test12_15;
import java.io.File;
import java.io.IOException;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder;
/**
*MyApp 类,清单文件配置
*/
import android.app.Application;
public class MyApp extends Application {
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
ImageLoader loader=ImageLoader.getInstance();
ImageLoaderConfiguration.Builder builder=new Builder(this);
try {
builder.diskCache(new LruDiskCache(new File("/storage/sdcard0/cache"),new Md5FileNameGenerator(),10*1024*1024));
} catch (IOException e) {
e.printStackTrace();
}
loader.init(builder.build());
}
}
/**
*调用的类
*/
ImageView image=(ImageView) findViewById(R.id.image);
builder = new DisplayImageOptions.Builder();
builder.cacheInMemory(true);
builder.cacheOnDisk(true);
builder.bitmapConfig(Config.RGB_565);
ImageLoader loader=ImageLoader.getInstance();
loader.displayImage("https://www.baidu.com/img/bd_logo1.png", image,builder.build());