2

该库允许从网络上自动下载和调整图像大小。这是网站 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
    }
});

这是我的代码:

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 不想编译返回此错误的代码。在 imageloader.loadImage 上,错误是

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(){})

在 OnloadingComplete 错误是

The method onLoadingComplete(String, View, Bitmap) of type new SimpleImageLoadingListener(){} must override or implement a supertype method

建议?

4

1 回答 1

0
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();
于 2014-06-27T03:57:06.633 回答