Android1.6:“android.view.WindowManager$BadTokenExc我试图打开一个对话框窗口,但是每次打开它都会抛出这个异常:Uncaught handler: thread main exiting due to uncaught exception
android.view.WindowManager$BadTokenException:
Unable to add window -- token null is not for an application
at android.view.ViewRoot.setView(ViewRoot.java:460)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.app.Dialog.show(Dialog.java:238)
at android.app.Activity.showDialog(Activity.java:2413)我是通过打电话来创建它的showDialog显示的身份。这个onCreateDialog处理程序日志很好,我可以在没有问题的情况下完成它,但是我已经附加了它,因为我似乎遗漏了一些东西:@Overridepublic Dialog onCreateDialog(int id){
Dialog dialog;
Context appContext = this.getApplicationContext();
switch(id)
{
case RENAME_DIALOG_ID:
Log.i("Edit", "Creating rename dialog...");
dialog = new Dialog(appContext);
dialog.setContentView(R.layout.rename);
dialog.setTitle("Rename " + noteName);
break;
default:
dialog = null;
break;
}
return dialog; }有什么东西不见了吗?创建对话框时,有一些问题谈到了这个问题。onCreate,这是因为活动尚未创建,但这是来自菜单对象的调用,而appContext变量似乎已在调试器中正确填充。
- 3 回答
- 0 关注
- 461 浏览
添加回答
举报
0/150
提交
取消