进入Activity就弹出PopupWindow 来,结果编译运行后报异常:“android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@983iefd89 is not valid; is your activity running? ”
后来发现,是要等Activity都进行完,才能pop出这个popupwindow;
解决方案:
在你所想弹出的布局中
yourLayout.post(new Runnable() {
@Override
public void run() {
mPopupWindows.showAtLocation(yourLayout,Gravity.CENTER, 0, 0);
}
});
分享到:
相关推荐
PopupWindow
实现的功能有弹出的PopupWindow上有EditText能与软键盘并存不冲突,弹出PopupWindow的时候背景自动改变灰度为半透明黑色,消失后背景灰度复原,PopupWindow还能根据自己的实际需求制定自己想要的弹出动画,以及...
android popupwindow 底部灰色背景
解决PopupWindow嵌套PopupWindow报的异常Unable to add window
PopupWindow之显示顶层对话框代码
仿微信popupwindow.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
popupwindow弹窗实现点击按钮,下方弹出popwindow,并且只是按钮下方有阴影,按钮以及上方没有阴影
自定义popupWindow修改版
android 封装一个通用PopupWindow,避免重复造轮子,简化代码,方便管理。
Android从屏幕底部滑动弹出PopupWindow,有动画效果,类似于sharesdk的分享页面滑动弹出效果。
AndroidListView+PopupWindow实现item点击弹出PopupWindow 博客地址:https://blog.csdn.net/dreams_deng/article/details/104618270
PopupWindow的简单使用!
android popupwindow小例子,包括popupwindow的位置摆放等待
仿微信右上角弹出PopupWindow的Demo,
Popupwindow点击事件+popupwindow以外的背景变暗 地址 : http://blog.csdn.net/u012062810/article/details/46873781
AS写的PopupWindow demo blog:http://blog.csdn.net/shenyuanqing/article/details/48136639