Problem in using ImageView

by Ravi Savaliya » Mon, 23 Jun 2008 16:28:20 GMT


Sponsored Links
 I am try to display image from internet. I have url  of image , that i
passed in constructing URI ref.

screen display blank

here is code,

 
-----------------------------------------------------------------------------------------------------------------------------------
      ImageView imageView = (ImageView) findViewById(R.id.imageView);

      Uri uri=Uri.parse(" http://static.px.yelp.com/upthumb/ 
q0POOE3vv2LzNg1qN8MMyw/ms");
      imageView.setImageURI(uri);
       setContentView(imageView);
-----------------------------------------------------------------------------------------------------------------------------------

any reply is appreciable

thanks

--~--~---------~--~----~------------~-------~--~----~



Problem in using ImageView

by Fr盲ntz Miccoli » Tue, 24 Jun 2008 16:14:18 GMT


 Hello Ravi,

I've solved this problem through an Input Stream I give you my code :

first how to put this stream in my imageView, mThumbnail:
mThumbnail.setImageDrawable(imageOperations(url, "name.jpg"));

now my imageOperations method :

        public static Drawable imageOperations(String url, String
saveFilename) {
                try {
                        InputStream is = (InputStream) fetch(url);
                        Drawable d = Drawable.createFromStream(is, "src");
                        return d;
                } catch (MalformedURLException e) {
                        e.printStackTrace();
                        return null;
                } catch (IOException e) {
                        e.printStackTrace();
                        return null;
                }
        }

and the fetch method :
        private static Object fetch(String address) throws
MalformedURLException,IOException {
                URL url = new URL(address);
                Object content = url.getContent();
                return content;
        }

It might not be the best way but it works. I found it on a blog...
don't remember which one.

Nice day.

Frntz




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. draw text as big as possible inside a rectangle

Is there any convenient method to draw a string (custom true type
font)
as big is possible inside a supplied rectangle or to calculate the
font
size of a paint object based on a string and some rectangle
dimensions.

Thanks in advance
Michael
--~--~---------~--~----~------------~-------~--~----~

2. Bytecode assembler

Is there a Dalvik Bytecode assembler?
(something similar to Jasmin in Java)
--~--~---------~--~----~------------~-------~--~----~

3. Number of Bluetooth Connections

4. Webview questions

5. Change TextView text in code

6. How to enable DUN in G1 phone?

7. More Than One Instance of Application