程序在警告对话框错误中意外关闭?

时间:2013-01-26 23:59:40

标签: android alertdialog

我有这个AlertDialog,并且当我选择yes选项时程序自动关闭时会出现错误。任何人也许可能是我做错了什么?这是代码和logcat。

new AlertDialog.Builder(HIITActivity.this)
.setIcon(R.drawable.ic_launcher)
.setTitle("[" + file.getName() + "]")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int id) {
           if(songchooser==1)
           {
            path1=file.getAbsolutePath();
           }
           else
           {
           path2=file.getAbsolutePath();
           }
            gohome(view);
       }
   })
.setNegativeButton("Cancel", 
  new DialogInterface.OnClickListener() {

   public void onClick(DialogInterface dialog, int which) {

    // TODO Auto-generated method stub

   }

  }).show();

}

    }});

继承logcat

 18:54:07.758: E/AndroidRuntime(296): Uncaught handler: thread main exiting due to uncaught exception
01-26 18:54:07.790: E/AndroidRuntime(296): java.lang.NullPointerException
01-26 18:54:07.790: E/AndroidRuntime(296):  at phil.H.com.HIITActivity.gohome(HIITActivity.java:102)
01-26 18:54:07.790: E/AndroidRuntime(296):  at phil.H.com.HIITActivity$3$2.onClick(HIITActivity.java:347)
01-26 18:54:07.790: E/AndroidRuntime(296):  at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
01-26 18:54:07.790: E/AndroidRuntime(296):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-26 18:54:07.790: E/AndroidRuntime(296):  at android.os.Looper.loop(Looper.java:123)
01-26 18:54:07.790: E/AndroidRuntime(296):  at android.app.ActivityThread.main(ActivityThread.java:4363)
01-26 18:54:07.790: E/AndroidRuntime(296):  at java.lang.reflect.Method.invokeNative(Native Method)
01-26 18:54:07.790: E/AndroidRuntime(296):  at java.lang.reflect.Method.invoke(Method.java:521)
01-26 18:54:07.790: E/AndroidRuntime(296):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-26 18:54:07.790: E/AndroidRuntime(296):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-26 18:54:07.790: E/AndroidRuntime(296):  at dalvik.system.NativeStart.main(Native Method)
01-26 18:54:07.811: I/Process(52): Sending signal. PID: 296 SIG: 3
01-26 18:54:07.811: I/dalvikvm(296): threadid=7: reacting to signal 3
01-26 18:54:08.008: I/dalvikvm(296): Wrote stack trace to '/data/anr/traces.txt'
01-26 18:54:10.358: I/Process(296): Sending signal. PID: 296 SIG: 9
01-26 18:54:10.408: I/ActivityManager(52): Process phil.H.com (pid 296) has died.
01-26 18:54:10.418: I/WindowManager(52): WIN DEATH: Window{44dcac08 phil.H.com/phil.H.com.HIITActivity paused=false}
01-26 18:54:10.488: I/WindowManager(52): WIN DEATH: Window{44dc86a8 phil.H.com/phil.H.com.HIITActivity paused=false}
01-26 18:54:10.768: I/UsageStats(52): Unexpected resume of com.android.launcher while already resumed in phil.H.com
01-26 18:54:10.808: W/InputManagerService(52): Got RemoteException sending setActive(false) notification to pid 296 uid 10029

0 个答案:

没有答案