当我尝试在适配器类中的onClickEventOccure上执行时出现错误 android.view.WindowManager $ BadTokenException:无法添加窗口-令牌null不适用于应用程序
这里是logcat:
07-27 14:53:46.249 30907-30907/com.sgrip E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sgrip, PID: 30907
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
at android.view.ViewRootImpl.setView(ViewRootImpl.java:583)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.Dialog.show(Dialog.java:298)
at com.sgrip.activities.Pending_Request$2.onClickEventOccure(Pending_Request.java:160)
at com.sgrip.adapter.AdapterNotification$3.onClick(AdapterNotification.java:67)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
我试图在recycleview的listitem上调用datepicker对话框,但出现此错误。
请帮助我解决这个问题。 预先感谢.....
答案 0 :(得分:0)
您应该使用Activity.this
而不是getApplicationContext()