Do you mean put the setContentView() before findViewById()? I tried
that but it still comes up blank. Sorry if I'm not understanding you.


On Mar 24, 7:49 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> murphy wrote:
> > Hi all, I'm trying to get animagetodisplayfrom aninternetsource
> > but nothing it coming up on my screen. After the button click which
> > calls the code I am presented with a blank screen. The code I'm using
> > is:
>
> > try {
> >                            URL url = new 
> > URL("http://code.google.com/android/
> > images/logo_android.gif");
> >                            URLConnection conn = url.openConnection();
> >                            conn.connect();
> >                            InputStream is = conn.getInputStream();
> >                            BufferedInputStream bis = new BufferedInputStream
> > (is);
> >                            Bitmap bm = BitmapFactory.decodeStream(bis);
> >                            bis.close();
> >                            is.close();
>
> >                            ImageViewimage= (ImageView)findViewById
> > (R.id.timetableImage);
> >                            setContentView(R.layout.timetable);
> >                            image.setImageBitmap(bm);
>
> >                        } catch (Exception e) {
> >                            // TODO Auto-generated catch block
> >                                    e.printStackTrace();
> >                            }
>
> > Can any one see what's wrong?
>
> Yes. You're calling setContentView().
>
> In most activities, setContentView() is called once, early in
> onCreate(). It is infrequently called in an event handler (e.g., button
> click callback).
>
> More importantly, any widgets you got after the first setContentView()
> and before the second setContentView() are unusable. Hence, your
> findViewById() call immediately before the setContentView() will return
> you a widget...but that widget is then taken off the screen by the
> setContentView().
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to