popwindow初始时弹出引发的Unable to add window --token null is not valid
来源:互联网 发布:java开发工程师累不累 编辑:程序博客网 时间:2024/05/16 11:15
今天在做项目的时候遇到了这个问题,当时我是这样写的
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);CommonUtils.initData(this);setContentView(R.layout.activity_search);mContext = this;httpInstance = new HttpInstance();initView();historyPop(); historyPop.showAsDropDown(findViewById(R.id.search_layout)); }
showAsDropDown,或者是在Activity的onCreate()函数里面调用了showAsDropDown,多半是后者,由于你的popupwindow要依附于一个activity,而activity的onCreate()还没执行完,没有pop可以弹出。
改成如下就好了,用一个线程或者在某个事件里进行。
private Handler popupHandler = new Handler(){ @Override public void handleMessage(Message msg) { switch (msg.what) { case 0: historyPop.showAsDropDown(findViewById(R.id.search_layout)); historyPop.update(); break; } } };
然后在onCreate方法中这样写
popupHandler.sendEmptyMessageDelayed(0, 100);
0 0
- popwindow初始时弹出引发的Unable to add window --token null is not valid
- PopWindow Unable to add window -- token null is not valid; is your activity running
- Unable to add window -- token null is not valid
- Unable to add window -- token null is not valid
- unable to add window token null is not valid
- AndroidException -Unable to add window -- token null is not valid;
- PopupWindow出现Unable to add window -- token null is not valid; is your activity running?
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- Unable to add window -- token null is not valid; is your activity running?
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- - Unable to add window -- token null is not valid; is your activity running?
- Unable to add window -- token null is not valid; is your activity running?
- unable to add window -- token null is not valid; is your activity running 错误解决办法
- PopupWindow出现Unable to add window -- token null is not valid; is your activity running?
- popupwindow使用之异常:unable to add window -- token null is not valid
- popupwindow使用之异常:unable to add window -- token null is not valid
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid
- Web.xml配置详解之context-param
- Android百度定位
- 多线程
- Tv上button焦点问题
- oracle判断是否是数字的函数
- popwindow初始时弹出引发的Unable to add window --token null is not valid
- Tomcat学习2.1(简单的Servlet容器)
- kaggle 各种评价指标之二 :Error Metrics for Classification Problems 分类问题错误度量
- 结构体定义使用小总结
- Oracle 两表关联更新
- 自定义navigationcontroller返回动画
- python 不是内部或外部命令
- 关于JavaScript判断语句的一个小坑
- 用js实现返回上一步操作