58495

Android Universal Image Loader AutoResize

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?

Answer1:

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

Recommend

  • android - delay while loading Bitmaps into ArrayList using UniversalImageLoader
  • How to add callout into individual annotation in map view
  • Custom Dialog Button called inside RecyclerView's onBindViewHolder
  • ListView performance is slow
  • how to passing listview images passing another activity [closed]
  • didSelectRowAtIndexPath method at PFQueryTableViewController
  • Android how to set a transparent image resource of a view? or Remove the image?
  • How to get a android ListView item selector to use state_pressed
  • How to Handle Click on Imageview in Custom Listview with image and Textview?
  • Android: How do you create an EditText field in java class
  • Picasso Taking time to load images
  • CloseOptionsMenu doesn't work?
  • Unable to resolve Static method?
  • Display java JPanel in a JFrame
  • How can I set a binding to a Combox in a UserControl?
  • Sort List of Strings By Version
  • Problems compiling files using JOGL
  • Parsing a CSV string while ignoring commas inside the individual columns
  • Swing - Get new component under mouseReleased
  • MVC3 Razor - ListBox pre-select not working
  • Set the selected item in dropdownlist in MVC3
  • ilmerge with a PFX file
  • Spring Data JPA custom method causing PropertyReferenceException
  • Can I display google adwords (AdView) in javafx on android
  • Validaiting emails with Net.Mail MailAddress
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • Cannot Parse HTML Data Using Android / JSOUP
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • JTable with a ScrollPane misbehaving
  • Getting Messege Twice Using IMvxMessenger
  • How to stop GridView from loading again when I press back button?
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • Android Heatmap on canvas or ImageView
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • How to load view controller without button in storyboard?