Android Universal Image Loader AutoResize

a 夏天 提交于 2019-12-24 02:23:26

问题


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?


回答1:


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();


来源:https://stackoverflow.com/questions/15041891/android-universal-image-loader-autoresize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!