【Android开发坑系列】之PopupWindow
生活随笔
收集整理的這篇文章主要介紹了
【Android开发坑系列】之PopupWindow
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
java.lang.NullPointerException
at android.widget.PopupWindow$1.onScrollChanged
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {try {final Field fAnchor = PopupWindow.class.getDeclaredField("mAnchor");fAnchor.setAccessible(true);Field listener = PopupWindow.class.getDeclaredField("mOnScrollChangedListener");listener.setAccessible(true);final ViewTreeObserver.OnScrollChangedListener originalListener = (ViewTreeObserver.OnScrollChangedListener) listener.get(mPopPm);ViewTreeObserver.OnScrollChangedListener newListener =new ViewTreeObserver.OnScrollChangedListener() {public void onScrollChanged() {try {View mAnchor = (View) fAnchor.get(mPopPm);if (mAnchor == null) {return;} else {originalListener.onScrollChanged();}} catch (Exception e) {e.printStackTrace();}}};listener.set(mPopPm, newListener);} catch (Exception e) {e.printStackTrace();}
if (mPopupWindow != null) {mPopupWindow.dismiss();mPopupWindow = null;}
轉(zhuǎn)載于:https://www.cnblogs.com/kaima/p/3160897.html
總結(jié)
以上是生活随笔為你收集整理的【Android开发坑系列】之PopupWindow的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 岁末年初3Q大战惊现高潮,360震撼推出
- 下一篇: window安全模式的用途