Unable to add window -- 终极解决方案

 在使用Popup Window时候,一般都会遇到:

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

一般给出的解决方案是延时几百毫秒。

我遇到的问题是延时了1秒种还不行。其实界面都显示了 Activity onresume也走了。

但是很怪的是:getWindowToken()一直为null.

最后直接用 window.getDecorView()() 来替换 mPopupWindow.showAtLocation(mWindow.getDecorView(), Gravity.CENTER, 0, 0);

目前还没发现什么问题。先这样解决吧


猜你喜欢

转载自blog.csdn.net/f327888576/article/details/53673616