>From PacManMainView, you would first get the parent view (the FrameLayout), and from there you can find the ImageView.
On Sun, May 17, 2009 at 5:16 PM, steve_macleod <[email protected]> wrote: > > So if I had: > > <FrameLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:layout_width="fill_parent" > android:layout_height="fill_parent"> > > <android.pacman.com.PacManMainView > android:id="@+id/pacman_main_view" > android:layout_width="fill_parent" > android:layout_height="fill_parent"> > </android.pacman.com.PacManMainView> > > <ImageView android:id="@+id/pacAnim" > android:src="@drawable/pac02" > android:layout_width="20px" > android:layout_height="20px"/> > </FrameLayout> > > How would I go about getting a reference to the ImageView from > PamManMainView? > > Thanks again > > > > On 18 May, 00:56, Marco Nelissen <[email protected]> wrote: >> If this is indeed the case, then the ImageView isn't actually there, >> so you can't get a reference to it. >> >> On Sun, May 17, 2009 at 4:45 PM, steve_macleod >> >> >> >> <[email protected]> wrote: >> >> > Thanks for the reply. >> > Ill look into this. What is the best way to get a reference to the >> > ImageView from the custom view code, if this is the case? >> >> > On 18 May, 00:19, Marco Nelissen <[email protected]> wrote: >> >> I'm not 100% sure, but I don't think a SurfaceView can have child >> >> views (since it's not a ViewGroup). >> >> >> On Sun, May 17, 2009 at 2:53 PM, steve_macleod >> >> >> <[email protected]> wrote: >> >> >> > Hi, >> >> > I have the following xml layout: >> >> >> > <android.pacman.com.PacManMainView >> >> > android:id="@+id/pacman_main_view" >> >> > android:layout_width="fill_parent" >> >> > android:layout_height="fill_parent"> >> >> >> > <ImageView android:id="@+id/pacAnim" >> >> > android:src="@drawable/pac02" >> >> > android:layout_width="20px" >> >> > android:layout_height="20px"/> >> >> >> > </android.pacman.com.PacManMainView> >> >> >> > PacManMainView extends SurfaceView. I can draw to this, it works OK. >> >> > However, when I attempt to get a reference to the ImageView from >> >> > PacManMainView like this: >> >> >> > @Override >> >> > public void surfaceCreated(SurfaceHolder holder) { >> >> > /* test reference to imageview >> >> > ImageView pacImageV = (ImageView) findViewById(R.id.pacAnim); >> >> > } >> >> >> > I get a null each time. Is there something real simple Im missing? >> >> >> > Thanks- Hide quoted text - >> >> >> - Show quoted text -- Hide quoted text - >> >> - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

