Unable to add window --token null is not valid;

今天遇到以下错误bug: html

android.view.WindowManager$BadTokenException: Unable to add window -- android

token null  is not valid; is your activity running? spa

最后终于发现是PopupWindow组件的使用问题,若是你直接在Activity建立的方法中初始化,则会有此错误 .net

所以总结:PopupWindow必须在某个事件中显示或者是开启一个新线程去调用,不能直在oncreate方法中显示一个PopupWindow,不然永远会有以上错误 线程


参考文章: htm

http://cb269267.iteye.com/blog/1787779 blog

http://blog.csdn.net/fulinwsuafcie/article/details/17192683 token

http://blog.sina.com.cn/s/blog_4b93170a0100q1km.html
事件

相关文章
相关标签/搜索