0

I was working on loading a combobox or in android terms a spinner. I was following this tutorial and I can't seem to get it working with my current app.

http://developer.android.com/guide/tutorials/views/hello-spinner.html

I first created an app that just loaded a spinner. It ran completely fine but when I tried adding it to my current code it crashes everytime. I have the combo box in a second "activity" or "page" so when the user clicks next page the user gets directed to the next page but the force close comes up before anything happens.

When I commented out the line s.setAdapter(adapter) and the program works without crashing(but obviously the spinner is not loaded). I was hoping my logcat would reveal some information on this but it doesnt seem to display anything.

The only difference I can see in my code is that it is file being called.

Any suggestions are greatly appreciated.

Thanks!

Edit:

Here is the LogCat

02-06 19:39:08.289: ERROR/SensorManager(2260): registerListener 4:gp2a Light Sensor delay:240
02-06 19:39:08.294: ERROR/SensorManager(2260): =======>>>Sensor Thread RUNNING <<<========
02-06 19:39:08.294: ERROR/SensorManager(2260): registerListener: com.android.server.PowerManagerService$9@477ecd90
02-06 19:39:08.504: ERROR/SensorManager(2260): registerListener 0:SMB380 delay:240
02-06 19:39:08.534: ERROR/SensorManager(2260): registerListener: android.view.WindowOrientationListener$SensorEventListenerImpl@47960660
02-06 19:39:08.544: ERROR/PowerManagerService(2260): setTargetLocked targetValue=116 target=116 nominalCurrentValue=11 ani=true
02-06 19:39:12.859: ERROR/AndroidRuntime(11972): Uncaught handler: thread main exiting due to uncaught exception
02-06 19:39:12.869: ERROR/AndroidRuntime(11972): java.lang.RuntimeException: Unable to start activity ComponentInfo{Jason.notify/Jason.notify.Screen2}: java.lang.NullPointerException
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.os.Looper.loop(Looper.java:123)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread.main(ActivityThread.java:4363)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at java.lang.reflect.Method.invokeNative(Native Method)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at java.lang.reflect.Method.invoke(Method.java:521)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at dalvik.system.NativeStart.main(Native Method)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972): Caused by: java.lang.NullPointerException
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at Jason.notify.Screen2.onCreate(Screen2.java:37)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
02-06 19:39:12.869: ERROR/AndroidRuntime(11972):     ... 11 more
02-06 19:39:39.359: ERROR/InfoAlarmWidget(2332): AllDay Event Count = 0
02-06 19:39:40.884: ERROR/SensorManager(2260): unregisterListener: com.android.server.PowerManagerService$9@477ecd90
02-06 19:39:41.359: ERROR/SensorManager(2260): unregisterListener: android.view.WindowOrientationListener$SensorEventListenerImpl@47960660
02-06 19:54:44.729: ERROR/NetworkStateTracker(2260): net.tcp.buffersize.hsdpa not found in system properties. Using defaults
Savvas Dalkitsis
  • 11,476
  • 16
  • 65
  • 104
Johnston
  • 2,873
  • 8
  • 29
  • 39
  • please provide full source code of the first activity in order to receive a satisfied answer. – AZ13 Feb 07 '12 at 00:47
  • Or at least a log cat of the error in question. – Ashterothi Feb 07 '12 at 00:49
  • @Az13 - i can but the error is in loading the spinner which happens in activity 2. Would you still like me to post activity one? – Johnston Feb 07 '12 at 00:53
  • @Pyrodante - here is the log cat .. i'll try to format it nicer – Johnston Feb 07 '12 at 00:57
  • 1
    It seems the value you are setting to adpater is null. Make sure you are not passing null values. You may add print statement and make sure that. – kosa Feb 07 '12 at 01:02
  • @thinksteep you were right. how do i get a value here? I am doing it exactly the same way as i did my example one and tutorial and they both seem to have values – Johnston Feb 07 '12 at 01:41

1 Answers1

1

You have a null pointer on your onCreate method.

Judging from the line you say you comment and it works, I would assume your s reference is null.

How do you assign it? You should be using a findViewById() call if you inflate your layout via xml (as is the Android way)

Savvas Dalkitsis
  • 11,476
  • 16
  • 65
  • 104