If you are just trying to make the ImageView display an image from a URL use
this function.
private Bitmap decodeImage(String url) {
URL aURL;
try {
aURL = new URL(url);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
return bm;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
call the function as
imgView.setImageBitmap(decodeImage("http://sss.jpg"));
Sincerely
Jose C Gomez
http://www.josecgomez.com
On Sat, May 1, 2010 at 12:20 PM, Mark Murphy <[email protected]>wrote:
> > On Apr 29, 6:13 pm, dylanh724 <[email protected]> wrote:
> >> Hello:
> >>
> >> All I want to do is display a URL image.
>
> What is "display a URL image"?
>
> >> Does anyone have a template I
> >> could use that already displays an image that I can possibly modify?
>
> Where and how are you trying to display an image? As a single image in a
> widget-based layout? As an image in a row of a ListView? As part of
> drawing on a Canvas for a 2D game? As part of rendering an OpenGL 3D
> animation? As an image on a Web page in an HTML5 application? Something
> else?
>
> >> I've been looking all over the internet and the only answers I've
> >> found are extremely complex.
>
> That is because doing it properly can be complex, depending on how you
> are using it. For example, putting thumbnails in a ListView can be a
> substantial amount of code, to handle downloading in the background,
> displaying the images in the list once they are downloaded, managing a
> cache so if you have 10,000 rows in the list you don't try downloading
> and holding onto 10,000 images, etc.
>
> The more you can explain about where and how you are trying to "display
> a URL image", the better people can help you with your questions.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android 2.x Programming Books: http://commonsware.com/books
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en