AlertDialog显示错误 Unable to add window token null is not for an application
来源:互联网 发布:淘宝悬浮导航栏尺寸 编辑:程序博客网 时间:2024/06/10 17:25
今天开发时遇到了个错误,如下:
google发现
- AlertDialog imageDialog = new AlertDialog.Builder(context).setTitle("状态操作").setItems(items, listener).create();
- imageDialog.show();
其中context为在OnCreate中
- context = getApplicationContext();
得到
异常原因:AlertDialog创建语句
- public AlertDialog.Builder (Context context)
中,不能使用getApplicationContext()得到的context,而必须使用Activity,所以解决如下
解决方法:语句修改为
- AlertDialog imageDialog = new AlertDialog.Builder(Activity.this).setTitle("状态操作").setItems(items, listener).create();
- imageDialog.show();
其中的Activity为当前Activity的名称
改为终于好了。
原地址:http://trinea.iteye.com/blog/1142122
参考: http://blog.csdn.net/yimo29/article/details/6004782
0 0
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog显示错误 Unable to add window token null is not for an application
- AlertDialog:Unable to add window -- token null is not for an application
- AlertDialog Unable to add window -- token null is not for an application
- 使用AlertDialog.Builder的时候出现错误:unable to add window --token null is not for an application的解决办法
- Unable to add window -- token null is not for an application错误的解决方法
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法
- Unable to add window -- token null is not for an application错误的解决方法 android开发
- 获取当前页面所在的controller
- pthread
- 如何让Excel 的Pivot表使用多张表的内容
- 解决mysql数据库中文乱码的问题
- Cookie/Session机制详解
- AlertDialog显示错误 Unable to add window token null is not for an application
- Windows常用网络排错命令
- myeclipse8.5 maven junit报ClassNotFoundException
- 设置Linux时间和日期
- Memcached集群/分布式/高可用 及 Magent缓存代理搭建过程 详解
- 彻底弄懂css中单位px和em,rem的区别
- Add Two Numbers
- Mac OS X上使用Wireshark抓包
- 算法设计题3.31-栈和队列-第3章-《数据结构习题集》-严蔚敏吴伟民版