06-25 07:37:52.745: ERROR/AndroidRuntime(1722): Uncaught handler: thread main exiting due to uncaught exception 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): java.lang.RuntimeException: Unable to start activity ComponentInfo {goodteamstudio.rdc/goodteamstudio.rdc.MainMenu}: java.lang.NullPointerException 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2268) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2284) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread.access$1800(ActivityThread.java:112) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.os.Handler.dispatchMessage(Handler.java:99) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.os.Looper.loop(Looper.java:123) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread.main(ActivityThread.java:3948) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at java.lang.reflect.Method.invoke(Method.java:521) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:782) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at dalvik.system.NativeStart.main(Native Method) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): Caused by: java.lang.NullPointerException 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at goodteamstudio.rdc.MainMenu.onCreate(MainMenu.java:314) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1123) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2231) 06-25 07:37:52.774: ERROR/AndroidRuntime(1722): ... 11 more
=============================== XML <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/goodteamstudio.rdc" android:layout_width="fill_parent" android:layout_height="fill_parent"> <goodteamstudio.game.CMainRun android:id="@+id/mainmenu_id" android:layout_width="fill_parent" android:layout_height="fill_parent"/> ========================= public class CMainRun extends View { public CMainRun(Context contexts,AttributeSet attrs) { super(contexts); context = contexts; …… } ======================= setContentView(R.layout.main); gamerun = (CMainRun)findViewById(R.id.mainmenu_id); ========================== gamerun = null ???????????? why?? On May 18, 6:52 pm, steve_macleod <steven_macl...@hotmail.com> wrote: > Hi Dianne - yup knocking up a wee pacman game to learn android.... > what gave it away? :) > > I was using standard drawables until I hit the issue of animating the > drawables. Thats when I started looking at ImageViews. > It was my understanding that I had to use an ImageView to achieve > frame-by-frame animation. Can it be done without ImageViews? Are there > any examples that I could look over? > > Thanks again > > On 18 May, 07:11, Dianne Hackborn <hack...@android.com> wrote: > > > > > Like I said in your other thread, you probably don't want to be doing this. > > If I am to assume from your code-snippet that you have some kind of PacMan > > game, where the game is implemented in a SurfaceView and the PacMan is an > > ImageView... seriously, you don't want to do this. > > > The purpose of SurfaceView is to give you a dedicated drawing surface, which > > you can render to directly, independently of the normal update mechanism of > > the view hierarchy. Using an ImageView to render things completely defeats > > that purpose. If you are writing a game, you should be drawing your > > graphics into the SurfaceView yourself and not using the view hierarchy of > > managing the element there. > > > On Sun, May 17, 2009 at 5:16 PM, steve_macleod > > <steven_macl...@hotmail.com>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 <marc...@android.com> 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 > > > > > <steven_macl...@hotmail.com> 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 <marc...@android.com> 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 > > > > > >> <steven_macl...@hotmail.com> 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 - > > > -- > > Dianne Hackborn > > Android framework engineer > > hack...@android.com > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see and > > answer them.- 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 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 -~----------~----~----~----~------~----~------~--~---