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();
}