此类使用第三方jar包,地址 http://download.csdn.net/detail/qq_28708411/9419960
import android.text.TextUtils;
import android.widget.ImageView;
import com.kashuo.baozi.android.KsApplication;
import com.kashuo.baozi.android.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
public class ImageLoad {
public static DisplayImageOptions getDefaultOPtions() {
return new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.no_pic).showImageOnFail(R.drawable.no_pic).cacheInMemory(true).cacheOnDisk(true)
.build();
}
public static void loadImage(String url, ImageView imageView) {
loadImage(url, imageView, getDefaultOPtions(), null);
}
public static void loadImage(String url, ImageView imageView, DisplayImageOptions options) {
loadImage(url, imageView, options, null);
}
public static void loadImage(String url, ImageView imageView, ImageLoadingListener imageLoadingListener) {
loadImage(url, imageView, getDefaultOPtions(), imageLoadingListener);
}
public static void loadImage(String url, ImageView imageView, DisplayImageOptions options, ImageLoadingListener imageLoadingListener) {
if (!KsApplication.getInstance().isLoadImageNoneWifi() || TextUtils.isEmpty(url)) {
url = "drawable://" + R.drawable.no_pic;//默认图片的路径
}
if (imageLoadingListener == null) {
ImageLoader.getInstance().displayImage(url, imageView, options);
} else {
ImageLoader.getInstance().displayImage(url, imageView, options, imageLoadingListener);
}
}
}