所以我叫活動和GameActivity.java
這個活動我打電話DialogAnswer.show()
這簡單的在屏幕上顯示的一些圖片。查看未連接到窗口管理器,對話框駁回
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:402)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:304)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:79)
at android.app.Dialog.dismissDialog(Dialog.java:325)
at android.app.Dialog.dismiss(Dialog.java:307)
at pl.evelanblog.prawdaczyfalsz.screen.DialogAnswer$1.onFinish(DialogAnswer.java:36)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:118)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
這是我DialogAnswer.java
類
public class DialogAnswer extends Activity {
private static ImageView resultImage;
private static Dialog dialog = null;
public static void show(Context context, boolean fCorrect) {
dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialog.setContentView(R.layout.dialog);
resultImage = (ImageView) dialog.findViewById(R.id.result_image);
if (fCorrect)
resultImage.setImageResource(R.drawable.correct_image);
else
resultImage.setImageResource(R.drawable.incorrect_image);
dialog.show();
new CountDownTimer(700, 100) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
dialog.dismiss(); //this is line 36
}
}.start();
}
}
當GameActivity.java
有時我會喜歡這個活動的另一個即時得到錯誤在我的崗位上。我不知道如何解決這個問題,它很難調試,因爲它很少有錯誤,但它存在。
這個問題是一個傻瓜,答案和幼稚,所以幫助別人就這個問題誰絆倒,解決方案的最好的總結,我發現到目前爲止這裏是:https://androidresearch.wordpress.com/2013/05/10/dealing-with-asynctask-and-screen-orientation/ –
你可以參考Ref ference從[這裏](https://stackoverflow.com/questions/2745061/java-lang-illegalargumentexception-view-not-attached-to-window-manager/45346389#45346389) –