2013-02-23 90 views
2

此庫允許從網絡上自動下載和調整圖像大小。 這是網站維基的代碼片段:Android通用圖像加載器AutoResize

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 

建議?

+0

DisplayImageOptions必須初始化,至少爲null。解決了。 – 2013-02-23 15:12:51

回答

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(); 
相關問題