Android的通用图像装载机自动调整 [英] Android Universal Image Loader AutoResize
本文介绍了Android的通用图像装载机自动调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这让库下载和从网上自动调整图像。
这是code在网站维基的片段:
IMAGESIZE的targetSize =新IMAGESIZE(120,80); //位图的结果将是适合这个尺寸
imageLoader.loadImage(imageUri,的targetSize,displayOptions,新SimpleImageLoadingListener(){
@覆盖
公共无效onLoadingComplete(字符串imageUri,观景,位图loadedImage){
//你想与任何位图
}
});
这是我的code:
ImageView的ImageView的=(ImageView的)findViewById(R.id.imageGrid1); //视图,该图像将显示
字符串图片网址=http://img33.imageshack.us/img33/9336/51863504.jpg;
ImageLoader的ImageLoader的= ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(本));
IMAGESIZE的targetSize =新IMAGESIZE(120,80);
DisplayImageOptions选择;imageLoader.loadImage(图片网址,的targetSize,期权,新SimpleImageLoadingListener(){
@覆盖
公共无效onLoadingComplete(字符串imageUri,观景,位图loadedImage){
//你想与任何位图
}
});
的Eclipse不想编译code返回此错误。
在imageloader.loadImage误差
在该行多个标记
- SimpleImageLoadingListener不能被解析为一个类型
- 在类型ImageLoader的方法的LoadImage(字符串,IMAGESIZE,DisplayImageOptions,ImageLoadingListener)是不适用的参数
(字符串,IMAGESIZE,DisplayImageOptions,新SimpleImageLoadingListener(){})
在OnloadingComplete误差
的方法类型onLoadingComplete(字符串,查看,位图)新SimpleImageLoadingListener(){}必须覆盖或实现超方法
建议?
解决方案
ptions =新DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_stub)
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error).cacheInMemory(真)
.cacheOnDisk(真).considerExifParams(真)
.displayer(新RoundedBitmapDisplayer(20))
.bitmapConfig(Bitmap.Config.RGB_565).build();
This library allow to download and resize automatically image from the web. This is the snippet of the code in the website wiki:
ImageSize targetSize = new ImageSize(120, 80); // result Bitmap will be fit to this size
imageLoader.loadImage(imageUri, targetSize, displayOptions, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// Do whatever you want with Bitmap
}
});
This is my code:
ImageView imageView = (ImageView)findViewById(R.id.imageGrid1); // view, where the image will be displayed
String imageUrl = "http://img33.imageshack.us/img33/9336/51863504.jpg";
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(this));
ImageSize targetSize = new ImageSize(120, 80);
DisplayImageOptions options;
imageLoader.loadImage(imageUrl, targetSize, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// Do whatever you want with Bitmap
}
});
Eclipse don't want to compile the code returning this error. On imageloader.loadImage the error is
Multiple markers at this line
- SimpleImageLoadingListener cannot be resolved to a type
- The method loadImage(String, ImageSize, DisplayImageOptions, ImageLoadingListener) in the type ImageLoader is not applicable for the arguments
(String, ImageSize, DisplayImageOptions, new SimpleImageLoadingListener(){})
on OnloadingComplete the error is
The method onLoadingComplete(String, View, Bitmap) of type new SimpleImageLoadingListener(){} must override or implement a supertype method
Suggestion?
解决方案
ptions = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.ic_stub)
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error).cacheInMemory(true)
.cacheOnDisk(true).considerExifParams(true)
.displayer(new RoundedBitmapDisplayer (20))
.bitmapConfig(Bitmap.Config.RGB_565).build();
这篇关于Android的通用图像装载机自动调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文