03-08 15:06:55.038: ERROR/AndroidRuntime(428): FATAL EXCEPTION: main
03-08 15:06:55.038: ERROR/AndroidRuntime(428): java.lang.RuntimeException: Unable to start activity ComponentInfo{shihaonan.SecretRoom/shihaonan.SecretRoom.ControllerPasswordCoverActivity}: java.lang.NullPointerException
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.os.Looper.loop(Looper.java:123)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at java.lang.reflect.Method.invokeNative(Native Method)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at java.lang.reflect.Method.invoke(Method.java:521)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at dalvik.system.NativeStart.main(Native Method)
03-08 15:06:55.038: ERROR/AndroidRuntime(428): Caused by: java.lang.NullPointerException
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at shihaonan.SecretRoom.ControllerPasswordCoverActivity.onCreate(ControllerPasswordCoverActivity.java:23)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-08 15:06:55.038: ERROR/AndroidRuntime(428):     ... 11 more

解决方案 »

  1.   

    把ControllerPasswordCoverActivity.java这个文件第23行代码发上来看一下
      

  2.   

    myButton.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     // Perform action on click
                  Intent intent = new Intent();
              intent.setClass(ControllerPasswordCoverActivity.this, ControllerDiaryContentActivity.class);
              ControllerPasswordCoverActivity.this.startActivity(intent);
              finish();
                 }
             });