I want to display image on screen. Image should come from URL, and not drawable.
Code is here:
<ImageView android:id="@+id/ImageView01" android:src = "http://l.yimg.com/a/i/us/we/52/21.gif" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
but it gives error at compile time.
How do I display image from URL in Android?
On your computer, go to images.google.com. Search for the image. In Images results, click the image. At the top of your browser, click the address bar to select the entire URL.
UIL is a powerful and flexible library for loading, caching and displaying images on Android.
You can directly show image from web without downloading it. Please check the below function . It will show the images from the web into your image view.
public static Drawable LoadImageFromWebOperations(String url) { try { InputStream is = (InputStream) new URL(url).getContent(); Drawable d = Drawable.createFromStream(is, "src name"); return d; } catch (Exception e) { return null; } }
then set image to imageview using code in your activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With