Android错误记录-WindowManager$BadTokenException: Unable to add window -
来源:互联网 发布:淘宝无线详情视频教程 编辑:程序博客网 时间:2024/06/06 07:18
错误产生:
- private
Context mcontext; -
-
-
void onCreate(Bundle savedInstanceState) {mcontext = getApplicationContext(); -
System.out.println( + mcontext); -
-
}
- new
AlertDialog.Builder(mcontext) -
.setIcon(android.R.drawable.ic_dialog_alert) -
.setTitle( -
.setMessage( -
forget )to write the message. Do you want to fill out it ??" -
.setPositiveButton( positiveListener).setNegativeButton( -
negativeListener).create().show();
导致报这个错是在于new AlertDialog.Builder(mcontext),虽然这里的参数是AlertDialog.Builder(Context context)但我们不能使用getApplicationContext()获得的Context,而必须使用Activity,因为只有一个Activity才能添加一个窗体。
解决方法:将new AlertDialog.Builder(Context context)中的参数用Activity.this(Activity是你的Activity的名称)来填充就可以正确的创建一个Dialog了。
- new
AlertDialog.Builder(MyActivity. this) -
.setIcon(android.R.drawable.ic_dialog_alert) -
.setTitle( -
.setMessage( -
forget )to write the message. Do you want to fill out it ??" -
.setPositiveButton( positiveListener).setNegativeButton( -
negativeListener).create().show();
1 0
- Android错误记录-WindowManager$BadTokenException: Unable to add window -
- android.view.WindowManager$BadTokenException: Unable to add window错误
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window -- token nul
- 异常android.view.WindowManager$BadTokenException: Unable to add window解决方法
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window异常
- android.view.WindowManager$BadTokenException: Unable to add window -- token
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window(转)
- 【已解决】android.view.WindowManager$BadTokenException: Unable to add window
- 解决android.view.WindowManager$BadTokenException: Unable to add window -- token .
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window --Unabletoaddwindow--tokenandroid
- ios-day06-02(UITableView常见属性、UITableViewCell的常见属性、性能优化等)
- android Camera 如何判断当前使用的摄像头是前置还是后置
- 自定义对话框之单选框。。title带图片,选项不带图片的
- 15个 MySQL 基础面试题,DBA 们准备好了吗?
- JavaScript Call()函数的总结
- Android错误记录-WindowManager$BadTokenException: Unable to add window -
- OSX平台视频格式简单处理 - 如何导入不同格式的视频到iTunes?
- Web前端开发面试题整理(HTML+CSS+JavaScript)
- 根据账号个数生成8位随机密码
- 关于Spring中的<context:annotation-config/>配置
- (原创)Android studio--Libs导入(已解决)
- C++ 重载关系操作符
- 您没有感觉到,当今时代工作生活真的很累么?
- 关于shell启动时调用的几个配置文件/etc/profile .profile .bash_profile .bashrc等