0
static final String[] Build_Options = new String[]
    {"A","B","C"};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    MapView mapView = (MapView) findViewById(R.id.Mapp);
    mapView.setBuiltInZoomControls(true);

      //InputStream is = mydbconnect();
   // InputStream is2 =mydbconnect2();

   // JSONArray jArray = getJSONobj(is);
   // JSONArray jArray2 = getJSONobj(is2); => Not relevant to this part of the code.


    Button alert = (Button) findViewById(R.id.button1);

    Spinner spinner = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(HelloGoogleMap.this, android.R.layout.simple_spinner_item, Build_Options);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    System.out.println("YESS!!!!!!");

    //ArrayAdapter<String> adapter = new ArrayAdapter<String>(HelloGoogleMap.this,android.R.layout.simple_spinner_item,List <String> spinnerArray);


    System.out.println("TEST");
    spinner.setAdapter(adapter);
    System.out.println("PASS");


返回的错误如下:

07-24 06:13:01.607: D/dalvikvm(959): GC freed 3589 objects / 247552 bytes in 117ms
07-24 06:13:02.577: D/dalvikvm(959): GC freed 2994 objects / 200040 bytes in 107ms
07-24 06:13:03.277: D/dalvikvm(959): GC freed 3838 objects / 262184 bytes in 144ms
07-24 06:13:03.346: I/System.out(959): YESS!!!!!!
07-24 06:13:03.357: I/System.out(959): NOOOOO!!!!
07-24 06:13:03.357: D/AndroidRuntime(959): Shutting down VM
07-24 06:13:03.357: W/dalvikvm(959): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-24 06:13:03.357: E/AndroidRuntime(959): Uncaught handler: thread main exiting due to uncaught exception
07-24 06:13:03.376: E/AndroidRuntime(959): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellogooglemap/com.example.hellogooglemap.HelloGoogleMap}: java.lang.NullPointerException
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.os.Looper.loop(Looper.java:123)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread.main(ActivityThread.java:4363)
07-24 06:13:03.376: E/AndroidRuntime(959):  at java.lang.reflect.Method.invokeNative(Native Method)
07-24 06:13:03.376: E/AndroidRuntime(959):  at java.lang.reflect.Method.invoke(Method.java:521)
07-24 06:13:03.376: E/AndroidRuntime(959):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-24 06:13:03.376: E/AndroidRuntime(959):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-24 06:13:03.376: E/AndroidRuntime(959):  at dalvik.system.NativeStart.main(Native Method)
07-24 06:13:03.376: E/AndroidRuntime(959): Caused by: java.lang.NullPointerException
07-24 06:13:03.376: E/AndroidRuntime(959):  at com.example.hellogooglemap.HelloGoogleMap.onCreate(HelloGoogleMap.java:85)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-24 06:13:03.376: E/AndroidRuntime(959):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
07-24 06:13:03.376: E/AndroidRuntime(959):  ... 11 more
07-24 06:13:03.406: I/dalvikvm(959): threadid=7: reacting to signal 3
07-24 06:13:03.477: I/dalvikvm(959): Wrote stack trace to '/data/anr/traces.txt'
07-24 06:18:03.446: I/Process(959): Sending signal. PID: 959 SIG: 9
4

1 回答 1

0

85号线是哪条线?

可能您的spinner为空,请检查视图 ID。

于 2012-07-24T06:23:38.690 回答