Skip to content

Instantly share code, notes, and snippets.

@oguya
Created January 6, 2014 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oguya/8279521 to your computer and use it in GitHub Desktop.
Save oguya/8279521 to your computer and use it in GitHub Desktop.
Load image from URL to an ImageView
//ImageLoader lib => http://search.maven.org/remotecontent?filepath=com/novoda/imageloader/imageloader-core/1.5.8/imageloader-core-1.5.8.jar
String image_url = "http://mycodeandlife.files.wordpress.com/2013/01/384088_2317070728022_2086719259_n.jpg";
ImageView image = (ImageView) findViewById(R.id.imageView1);
// Get singletone instance of ImageLoader
ImageLoader imageLoader = ImageLoader.getInstance();
// Initialize ImageLoader with configuration. Do it once.
imageLoader.init(ImageLoaderConfiguration.createDefault(this));
// Load and display image asynchronously
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher) //this is the image that will be displayed if download fails
.cacheInMemory()
.cacheOnDisc()
.build();
imageLoader.displayImage(image_url, image, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment