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(;

      Uri uri=Uri.parse(" 

any reply is appreciable



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) {
                        return null;
                } catch (IOException e) {
                        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.



Sponsored Links

Other Threads

1. Problems with uploading files to webservice


I have a rest webservice that takes a POST metod with multipart

public String multipartTest(com.sun.jersey.multipart.MultiPart data)
try {
// get first body part (index 0)
BodyPart bp = multiPart.getBodyParts().get(0);

Now I tried to write a client on android to send a file to this
server. So I used the normal way to send multipart message on android:

    HttpClient client = new DefaultHttpClient();
 client.getParams().setParameter("http.socket.timeout", new
Integer(90000)); // 90 second

HttpPost httpPost = new HttpPost("
 httpPost.setHeader("Content-Type", MediaType.MULTIPART_FORM_DATA );

//tried with and without base64
 byte [] encodedWavestream = Base64.encodeBytesToBytes(wavestream);
 InputStream ins = new ByteArrayInputStream(encodedWavestream);
 InputStreamBody body = new InputStreamBody(ins, "test" );
 int send = ins.available();

MultipartEntity requestContent = new
MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE );
requestContent.addPart("stream", body);

HttpResponse Response = client.execute(httpPost);

An this gives an annoying response from the server :

HTTP Status 400 - Bad Request
The request sent by the client was syntactically incorrect (Bad

I check the server log files but there is nothing there. So I don't
know what's the origin of this error. I have wrote a simple html page
with a post formula and 'multipart/form-data' content-type and it
works. I created a Jersey client on a PC and it also works. However I
have big problems with implementing this Jersey api on android. Why my
android client does not work? Can anybody help please?


2. how to merge column of a table

I have a table which has four columns as say (RoomId, RoomName,
SwitchID, SwitchName.)
Now I want to merge last three columns depending upon first column(i.e

means supppose in a table I have following data

2:Guest Room:4:cooler
2:Guest Room:5:Bulb
4:Guest Room:10:cooler
5:Study Room:11:AC
5:Study Room:12:Tube
2::Guest Room:13:Bulb

Now what I want is depending upon first column (i.e RoomID) other
column must have to be merge and therefore data will be like this


How it is do?



3. Q: How to do an expand animation?

4. android edittext

5. Slow execution getThumbnail in HTC hero

6. Accessing style items by style ID

7. "Local" Service vs "Remote" Service