Hi use this code also

 public class imageloader implements Runnable{

                private String ss;
                        //private View v;
                        //private View v2;
                        private ImageView im;

                 public imageloader(String s,  ImageView im) {
                         this.ss=s;
                        //this.v2=v2;
                         this.im=im;
                         Thread thread = new Thread(this);
                     thread.start();
                            }
                        public void run(){
                     try {
                            // URL url = new URL(ss);
                            // URLConnection conn = url.openConnection();
                            // conn.connect();
                         HttpGet httpRequest = null;
                                      httpRequest = new HttpGet(ss);
                                      HttpClient httpclient = new 
DefaultHttpClient();
                                        HttpResponse response = (HttpResponse)
httpclient.execute(httpRequest);
                                        HttpEntity entity = 
response.getEntity();
                                        BufferedHttpEntity bufHttpEntity = new
BufferedHttpEntity(entity);
                             InputStream is = bufHttpEntity.getContent();
                           //  BufferedInputStream bis = new
BufferedInputStream(is);
                             Bitmap bm = BitmapFactory.decodeStream(is);
                             Log.d("img","img");
                            // bis.close();
                             is.close();
                             im.setImageBitmap(bm);
                            // im.forceLayout();
                            // v2.postInvalidate();
                           //  v2.requestLayout();
                     } catch (Exception t) {
                                Log.e("bitmap url", "Exception in 
updateStatus()", t);
                                //goBlooey(t);
                                // throw new RuntimeException(t);
                        }

             }


On Mar 4, 8:30 am, Beena <[email protected]> wrote:
> Thanks A R.
>
> I will try as you have suggested then will tell you if any problem
> occure.
>
> Again thanks for the reply.
>
> On Mar 4, 2:43 am, A R <[email protected]> wrote:
>
>
>
> > public interface MyListener {
> >  public void success();
> >  public void failure();
>
> > }
>
> > From your activity:
>
> > myServerConnectionHandlerObject.getImages(new MyListener() {
> >  //implement both methods here.
>
> > });
>
> > public class MyServerConnectionHandler {
> >   public void getImages(MyListener l) {
> >     //do net stuff on success call l.success(), on failure l.failure()
> >   }
>
> > }
>
> > This is very basic, you need to expand and handle various scenarios
>
> > On Mar 3, 3:16 pm, Beena <[email protected]> wrote:
>
> > > Thanks A R for your instant reply,
> > > That is what I want actually.
>
> > > Can you give some sample code?
> > > I am not able to understand how to set the listener method to update
> > > the view.
>
> > > Thanks
>
> > > On Mar 3, 2:55 pm, A R <[email protected]> wrote:
>
> > > > Start the second activity immediately on start check whether you have
> > > > images to display or not if not create a separate thread (important it
> > > > should be separate thread) to get the images. To this separate thread
> > > > you should pass a listener (which can be your second activity or an
> > > > inner class), when thread gets data it will call the listener's method
> > > > which can update the view.
> > > > During the time when you don't get response you can show loading/
> > > > spinner. Once image comes you can replace spinner with your image.
> > > > HTH
>
> > > > On Mar 3, 2:43 pm, Beena <[email protected]> wrote:
>
> > > > > Let me explain.
>
> > > > > I want to display the Images(which is from server) and its data in
> > > > > right side of image.
> > > > > To load the images from server I am using this.
>
> > > > >                 Bitmap bmImg=null;
> > > > >                 URL myFileUrl =null;
> > > > >                 HttpURLConnection conn=null;
> > > > >                 try {
> > > > >                 myFileUrl= new URL(fileUrl);//fileUrl is the image 
> > > > > path
> > > > >                 } catch (MalformedURLException e) {
> > > > >                 e.printStackTrace();
> > > > >                 }
> > > > >                 try {
> > > > >             conn= (HttpURLConnection)myFileUrl.openConnection();
> > > > >                 conn.setDoInput(true);
> > > > >                 conn.connect();
> > > > >                 int length = conn.getContentLength();
> > > > >                 int[] bitmapData =new int[length];
> > > > >                 byte[] bitmapData2 =new byte[length];
> > > > >                 InputStream is = conn.getInputStream();
>
> > > > >                 bmImg = BitmapFactory.decodeStream(is);
> > > > >                 conn.disconnect();
> > > > >                 } catch (IOException e) {
> > > > >                  conn.disconnect();
> > > > >                  return bmImg;
> > > > >                 }
>
> > > > > It will work fine but it will first fetch all the images and then it
> > > > > will display.
> > > > > So it takes lots of time to go for next activity in between there
> > > > > comes black screen as well which i don't want.
>
> > > > > So i want to use the Threading. So first the data of the images will
> > > > > be displayed at their position and then as the image load it will
> > > > > display at their respective place.
>
> > > > > Thanks for the response.
>
> > > > > On Mar 3, 1:34 pm, A R <[email protected]> wrote:
>
> > > > > > Beena, I am not able to understand your problem?
>
> > > > > > Assuming you are displaying image and content in a list view, you 
> > > > > > want
> > > > > > to keep refreshing the view as and when images come? or you want to
> > > > > > make request for images and corresponding data separately and show
> > > > > > them as and when they come or together?
>
> > > > > > On Mar 3, 12:51 pm, Beena <[email protected]> wrote:
>
> > > > > > > Is there any one?
>
> > > > > > > Please help.
>
> > > > > > > On Mar 2, 6:26 pm, Beena <[email protected]> wrote:
>
> > > > > > > > Hi,
> > > > > > > > I am facing some strange thing.
> > > > > > > > I have a to display 15 images (from the server) and their 
> > > > > > > > detail in
> > > > > > > > besides that.
> > > > > > > > In Activity-A on button Click listener i am fetching the data 
> > > > > > > > and
> > > > > > > > image urls from the sever.
> > > > > > > > And in Activity-B I am displaying that images and the 
> > > > > > > > appropriate
> > > > > > > > data.
>
> > > > > > > > So how can i use the multithreading so that the information will
> > > > > > > > display at their position and as the image is load it will 
> > > > > > > > display the
> > > > > > > > image at the appropriate location means multithreading. So no 
> > > > > > > > need to
> > > > > > > > wait the user to load whole images.
>
> > > > > > > > I am trying through Handler() but it is also not working fine.
>
> > > > > > > > Please reply.
>
> > > > > > > > If further explanation needed than its welcome.
>
> > > > > > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to