Unable to add window -- token null is not for an application
2016-09-29 10:44
369 查看
android.view.WindowManager$BadTokenException:Unable to add window -- token null is not for anapplication
分析:
问题在于newAlertDialog.Builder(Context),虽然这里的参数是AlertDialog.Builder(Contextcontext)
但我们不能使用getApplicationContext()获得的Context,而必须使用Activity的Context对象,因为只有一个Activity才能添加一个窗体。
解决方法:
将new AlertDialog.Builder(Contextcontext)中的参数用Activity的Context对象即可.
分析:
问题在于newAlertDialog.Builder(Context),虽然这里的参数是AlertDialog.Builder(Contextcontext)
但我们不能使用getApplicationContext()获得的Context,而必须使用Activity的Context对象,因为只有一个Activity才能添加一个窗体。
解决方法:
将new AlertDialog.Builder(Contextcontext)中的参数用Activity的Context对象即可.
相关文章推荐
- Linux下XWindow图形界面的基本概念
- Access to SQLserver 数据库生迁脚本编写器(DB_CreateSqlEV1.06下载)
- WMA To MP3 Encoder6.15绿色版含注册文件 下载
- 快速掌握Node.js之Window下配置NodeJs环境
- C# LINQ to XML应用介绍
- Linq to SQL Delete时遇到问题的解决方法
- easyui window refresh 刷新两次的解决方法(推荐)
- Vue.js报错Failed to resolve filter问题的解决方法
- How to Auto Include a Javascript File
- 判断window.onload是否多次使用的方法
- javascript add event remove event
- Javascript中封装window.open解决不兼容问题
- jquery自定义插件开发之window的实现过程
- jquery自定义插件――window的实现【示例代码】
- Easy RM RMVB to DVD Burner v1.3.8 汉化版 下载 附注册码
- window.returnValue使用方法示例介绍
- javascript类型系统 Window对象学习笔记
- DISCUZ在win2003环境下 Unable to access ./include/common.inc.php in... 的问题终极解决方案
- window系统的Rsync同步实战分析第1/2页
- JavaScript中window、doucment、body的解释