首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Dialog 出现的android.view.WindowManager$BadTokenException: Unable to add window错误

2012-09-24 
Dialog 出现的android.view.WindowManager$BadTokenException: Unable to add window异常Dialog异常:andro

Dialog 出现的android.view.WindowManager$BadTokenException: Unable to add window异常

Dialog异常:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

异常原因:
new AlertDialog.Builder(Context context)中的参数不能用getApplicationContext()获得的context,而必须使用Activity,因为只有一个Activity才能添加一个窗体。

解决办法:
例如 new AlertDialog.Builder(XXXActivity.this)

?

热点排行