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. How to run an apk with UID root

Hi,

          I have an application(apk) which normally gets uid as
app_16. Internally it calls a Shared library, which tries to write to
HCI socket(bluetooth socket). Here the socket which is created has
bluetooth UID and GID. It is not allowing to write to that socket.

Can any body give me suggestion what all permissions should be given
in manifest file to make it work. I have bluetooth and bluetooth admin
in Manifest file.

or Any thing should be added to framework such that my apk and library
gets permissions to aceeses HCI socket.

regards
KSK.

2. Problems with executing 'substring':

Hello,

I am wondering whether 'substring' support is there or not on Android 1.1 
minimum SDK set in Eclipse project. Actually i installed Android 1.6 SDK.
I use the following parse function, where-in i use 'substring' for few places. 
I am not getting any result from the 'substring' code and it jumps to 
Timer.class file to show 'The JAR of this class file belongs to 'Android 1.1 
which does not allow modifications to source attachments on its entities' etc. 
message, when debugging 'substring' line of code. 
I don't know why it is not executing 'substring' line of code in my below 
function and jumps to show such message like that to me?
Note: This function is under Timer running code.

private String parseContentsString(String inputDataStr)
 {
 String parsedOutput = null;
 int i = 0;
 int nameIndEnd = 0;
 int startIndex = 0;
 int endIndex = 0;
 
 i = inputDataStr.indexOf("TickerTxt>");
 if (i != -1)
 {
 nameIndEnd = inputDataStr.indexOf("", i);
 if (nameIndEnd > 0)
 {
 startIndex = i + 10;
 endIndex = nameIndEnd - startIndex;
 parsedOutput += " ";
 parsedOutput = inputDataStr.substring(startIndex, endIndex);
 parsedOutput += " ";
 }
 }
 while ((i = inputDataStr.indexOf("name=", i)) != -1)
 {
 nameIndEnd = inputDataStr.indexOf("target=", i);
 startIndex = i + 5;
 endIndex = (nameIndEnd - 2) - startIndex;
 if (i > 0 && nameIndEnd > 0)
 {
 parsedOutput += inputDataStr.substring(startIndex, endIndex);
 parsedOutput += " ";
 }
 i = inputDataStr.indexOf("<B>", i);
 startIndex = i + 3;
 nameIndEnd = inputDataStr.indexOf("</B>", i);
 endIndex = nameIndEnd - startIndex;
 if (i > 0 && nameIndEnd > 0)
 {
 parsedOutput += inputDataStr.substring(startIndex, endIndex);
 parsedOutput += " ";
 } 
 i = inputDataStr.indexOf("font color=", i);
 i = inputDataStr.indexOf(">", i);
 startIndex = i + 1;
 nameIndEnd = inputDataStr.indexOf("", i);
 endIndex = nameIndEnd - startIndex;
 if (i > 0 && nameIndEnd > 0)
 {
 parsedOutput += inputDataStr.substring(startIndex, endIndex);
 parsedOutput += " ";
 }  
 i = inputDataStr.indexOf("", i);
 startIndex = i + 12;
 nameIndEnd = inputDataStr.indexOf("%]", i);
 endIndex = (nameIndEnd + 2) - startIndex;
 if (i > 0 && nameIndEnd > 0)
 {
 parsedOutput += inputDataStr.substring(startIndex, endIndex);
 parsedOutput += " ; ";
 }
 i++;
 }
 return parsedOutput;
 }
 
Could someone help me on get rid of this problem and to execute 'substring' 
successfully?


Martin.



      

--

3. Transmit serialized object via HTTP in Android

4. Transmit serialized object via HTTP in Android?

5. creating multiple tables in a single databse in android

6. can i access opencore modules at application level?

7. Editor Layout problem