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. Problems with uploading files to webservice

Hello,

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

@Path("transferFile")
 @POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_XML)
public String multipartTest(com.sun.jersey.multipart.MultiPart data)
{
try {
// get first body part (index 0)
BodyPart bp = multiPart.getBodyParts().get(0);
etc..

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("http://127.0.0.1:8080/webapp/
transferFile");
 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);

httpPost.setEntity(requestContent);
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
Request).

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

Hi,
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
RoomID)

means supppose in a table I have following data

1:BedRoom:1:AC
1:BedRoom:2:CFL
1:BedRoom:3:Tube
2:Guest Room:4:cooler
2:Guest Room:5:Bulb
3:Kitchen:6:CFL
3::Kitchen:7:Fan
3:::Kitchen:8:TV
1::BedRoom:9:cooler
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

1:BedRoom:1:AC:2:CFL:3:Tube:9:cooler

How it is do?

Thanks

-- 

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