Dialog(四)——报错Unable to add window -- token null is not for an application
来源:互联网 发布:rufus制作linux启动盘 编辑:程序博客网 时间:2024/04/30 03:20
/** * 问题描述: * 创建和显示对话框的时候报错 * Unable to add window -- token null is not for an application * * 问题修正: * 不可使用Builder builder=new Builder(getApplicationContext()); * 应该使用Builder builder=new Builder(MainActivity.this); */private void showDialog(){ Dialog dialog; //正确 Builder builder=new Builder(MainActivity.this); //错误 //Builder builder=new Builder(getApplicationContext()); builder.setIcon(R.drawable.ic_launcher); builder.setTitle(getResources().getString(R.string.dialog_title)); builder.setMessage(R.string.dialog_message); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int arg1) {}}); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int arg1) {}}); dialog=builder.create(); dialog.show(); }
0 0
- Dialog(四)——报错Unable to add window -- token null is not for an application
- android报错——Unable to add window -- token null is not for an application
- Dialog throwing "Unable to add window — token null is not for an application” with getApplication()
- 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(创建Dialog出错)
- 在创建一个Dialog时,发生的错误: Unable to add window -- token null is not for an application
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- WindowManager$BadTokenException: 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 的解决办法
- Unable to add window -- token null is not for an application
- AlertDialog: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
- linux下源码安装软件
- linux下lnmp环境搭建
- maven 导入eclipse 问题
- 淘宝内核对LVS的性能优化
- 用什么方法可以恢复文件丨工作文件丢失了怎么恢复丨
- Dialog(四)——报错Unable to add window -- token null is not for an application
- Hadoop Streaming 实战: 传递环境变量
- 父类引用指向子类对象(Java中的多态)
- 关于onNewIntent的使用
- 安卓apk文件英汉对照表
- 优秀项目
- cocos2dx winphone环境搭建
- Kinect——颜色深度图像的显示:初始化、绑定流、提取流。
- 旅游搜索集团Momondo获得500万英镑信贷支持