Created
January 6, 2014 07:45
-
-
Save oguya/8279521 to your computer and use it in GitHub Desktop.
Load image from URL to an ImageView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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