Unable to add window错误
来源:互联网 发布:无法连接主机 端口23 编辑:程序博客网 时间:2024/06/06 20:22
Android.view.WindowManager$BadTokenException:Unableto add window—token android.app.LocalActivityManager$LocalActivityRecrd@4056eaa()is not valid;is your activity running?
在TabActivity的子Activity中创建对话框时出现的这个异常,这个异常出现的地方是在创建Dialog的时候的context上下文环境不匹配,在网上查了许多资料,有的说将getApplicationContext()改为Activity.this,试过了还是没用。后来仔细想了一下创建这个Dialog的坏境应该为当前Activity的父亲的坏境,于是改成CurrentActivity.this.getParent();即可.
Builder builder = new AlertDialog.Builder(CurrentActivity.this.getParent());
finalEditText edit = new EditText(CurrentActivity.this.getParent());
builder.setTitle("请输入组名");
builder.setView(edit);
builder.setPositiveButton("添加",
newDialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface dialog, int which) {
}
});
builder.setNegativeButton("取消",
newDialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
- Unable to add window错误
- Unable to add window错误
- android ProgressDialog错误:Unable to add window
- Android ProgressDialog错误:Unable to add window
- Unable to add window
- spinner 报unable to add window错误的解决
- Android错误记录-WindowManager$BadTokenException: Unable to add window -
- 关于Android的一个常见错误:Unable to add window
- android.view.WindowManager$BadTokenException: Unable to add window错误
- AlertDialog Unable to add window
- WindowManager$BadTokenException: Unable to add window
- android-view-windowmanagerbadtokenexception-unable-to-add-window
- Unable to add window崩溃分析
- Unable to add window崩溃分析
- Unable to add window -- 终极解决方案
- WindowManager$BadTokenException: Unable to add window
- 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
- ARM中断
- jQuery 03 DOM操作
- Android基础知识学习——界面转换
- iOS: NSObject的方法cancelPreviousPerformRequestsWithTarget:selector:object:
- 最近在折腾VPS(持续完善)
- Unable to add window错误
- ibatis使用3
- haar——nosecascade
- IIS+WAMP配置php + asp开发环境
- What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR
- Java编写软件
- 五位以内的对称素数
- Ubuntu下配置tftp服务和NFS服务
- Django的安装(windows下)