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 <mmurphy@commonsware.com> wrote:
> On Apr 29, 6:13 pm, dylanh724 <dylanh...@gmail.com> wrote:What is "display a URL image"?
>> Hello:
>>
>> All I want to do is display a URL image.
Where and how are you trying to display an image? As a single image in a
>> Does anyone have a template I
>> could use that already displays an image that I can possibly modify?
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?
That is because doing it properly can be complex, depending on how you
>> I've been looking all over the internet and the only answers I've
>> found are extremely complex.
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.
http://commonsware.com/blog | http://twitter.com/commonsguy
--
Mark Murphy (a Commons Guy)
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment