Just found it. Looks like I was using the old ID notation in the
layout xml.
I had

id="@+id/entry"

when I needed

android:id="@+id/entry"


On Jan 13, 9:43 pm, steve_macleod <[email protected]> wrote:
> It looks like
>
> mTa.setText(mTxt);
>
> is generating the NullPointerException because the line
>
> mTa = (TextView) findViewById(R.id.entry);
>
> is not returning a reference to the TextView. This component is in the
> layout XML, and has an ID assigned (I can see it on the R.java file).
> Can you think of any reason this would return null?
>
> thanks
>
> On Jan 13, 9:12 pm, steve_macleod <[email protected]> wrote:
>
>
>
> > Ok, I removed the second argument, and tried again, same error. The
> > console provides the following:
>
> > 01-13 21:09:27.015: INFO/ActivityManager(51): Displayed activity
> > com.android.hello/.HelloAndroid: 948 ms
> > 01-13 21:09:29.735: WARN/KeyCharacterMap(429): No keyboard for id 0
> > 01-13 21:09:29.735: WARN/KeyCharacterMap(429): Using default keymap: /
> > system/usr/keychars/qwerty.kcm.bin
> > 01-13 21:09:29.956: DEBUG/AndroidRuntime(429): Shutting down VM
> > 01-13 21:09:29.966: WARN/dalvikvm(429): threadid=3: thread exiting
> > with uncaught exception (group=0x40010e28)
> > 01-13 21:09:29.976: ERROR/AndroidRuntime(429): Uncaught handler:
> > thread main exiting due to uncaught exception
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):
> > java.lang.NullPointerException
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > com.android.hello.HelloAndroid.onKeyUp(HelloAndroid.java:32)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.view.KeyEvent.dispatch(KeyEvent.java:720)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.app.Activity.dispatchKeyEvent(Activity.java:1859)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
> > (PhoneWindow.java:1528)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.view.ViewRoot.deliverKeyEvent(ViewRoot.java:1616)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.view.ViewRoot.handleMessage(ViewRoot.java:1114)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.os.Handler.dispatchMessage(Handler.java:88)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.os.Looper.loop(Looper.java:123)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > android.app.ActivityThread.main(ActivityThread.java:3742)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > java.lang.reflect.Method.invoke(Method.java:515)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> > (ZygoteInit.java:739)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> > 01-13 21:09:29.995: ERROR/AndroidRuntime(429):     at
> > dalvik.system.NativeStart.main(Native Method)
> > 01-13 21:09:30.017: INFO/Process(51): Sending signal. PID: 429 SIG: 3
> > 01-13 21:09:30.036: INFO/dalvikvm(429): threadid=7: reacting to signal
> > 3
> > 01-13 21:09:30.085: INFO/dalvikvm(429): Wrote stack trace to '/data/
> > anr/traces.txt'
> > 01-13 21:09:32.126: DEBUG/dalvikvm(90): GC freed 2152 objects / 132888
> > bytes in 95ms
> > 01-13 21:09:33.446: INFO/Process(429): Sending signal. PID: 429 SIG: 9
> > 01-13 21:09:33.475: INFO/ActivityManager(51): Process
> > com.android.hello (pid 429) has died.
> > 01-13 21:09:33.527: INFO/WindowManager(51): WIN DEATH: Window{4345a460
> > com.android.hello/com.android.hello.HelloAndroid}
>
> > On Jan 12, 2:13 pm, Mark Murphy <[email protected]> wrote:
>
> > > steve_macleod wrote:
> > > > Ok thanks for this. I will look into these.
>
> > > > Do you have any idea why its crashing on this line?
>
> > > > mTa.setText(mTxt, TextView.BufferType.EDITABLE);
>
> > > I was hoping your error log would give you (and/or me) a clue.
>
> > > You do not need the second parameter, so try it with just the first.
>
> > > If that does not clear up your problem, then please review your error log.
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com
> > > _The Busy Coder's Guide to Android Development_ Version 2.0 Published!- 
> > > 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 Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to