0
我的代碼運行良好,但突然當我再次運行代碼時,它給了我堆棧溢出錯誤。以下是我的代碼:HelloDatePickerActivity已被定義。Stack Overflow錯誤android?
HelloDatePickerActivity daten=new HelloDatePickerActivity();
static final int DATE_DIALOG_ID = 0;
Button mPickDate;
TextView mDateDisplay;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offline_screen);
mPickDate=(Button)findViewById(R.id.pickDate);
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
daten.mDateSetListener,
daten.mYear, daten.mMonth, daten.mDay);
}
return null;
}
}
而且logcat的是:
08-26 15:38:50.039: ERROR/AndroidRuntime(585): FATAL EXCEPTION: main
08-26 15:38:50.039: ERROR/AndroidRuntime(585): java.lang.StackOverflowError
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at java.lang.Thread.currentThread(Thread.java:558)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at java.lang.ThreadLocal.get(ThreadLocal.java:53)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.os.Looper.myLooper(Looper.java:157)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.os.Handler.<init>(Handler.java:119)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at android.app.Activity.<init>(Activity.java:728)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:14)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerActivity.<init>(HelloDatePickerActivity.java:20)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.ACB_OnlineScreenActivity.<init>(ACB_OnlineScreenActivity.java:23)
08-26 15:38:50.039: ERROR/AndroidRuntime(585): at acb.xiynove.HelloDatePickerA
它以前運行良好與此代碼呢! – ross
HelloDatePickerActivity已經被定義 – ross
@ross:在你尚未初始化ACB_OlineScreenActivity之前呢?只是猜測;) – ZeissS