2 qq 22934323 qq_22934323 于 2016.04.20 14:53 提问

自定义软键盘用popupwindow弹出,点击按钮报错Unable to add window

自定义的键盘用的android.inputmethodservice.KeyboardView系统的软键盘
然后点击其中一个按钮就会报错
报的错:
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@41601028 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:513)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
at android.view.Window$LocalWindowManager.addView(Window.java:537)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:845)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:809)
at android.inputmethodservice.KeyboardView.showKey(KeyboardView.java:960)
at android.inputmethodservice.KeyboardView.access$100(KeyboardView.java:69)
at android.inputmethodservice.KeyboardView$1.handleMessage(KeyboardView.java:260)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

3个回答

CSDNXIAON
CSDNXIAON   2016.04.20 15:03
weixin_36631046
weixin_36631046   2017.05.11 16:19

请问你解决了么,我也遇到了这个问题

weixin_36631046
weixin_36631046   2017.05.11 16:26

哥们儿,你要回一下我啊

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!