YViewPagerDemo icon indicating copy to clipboard operation
YViewPagerDemo copied to clipboard

Crashes while adding fragments dynamically

Open chitrang200889 opened this issue 6 years ago • 0 comments

First of all, great work for vertical viewpager, and many thanks for contributing it as open source. As well-know solution is not working for Android Pie https://stackoverflow.com/questions/53684461/vertical-viewpager-and-android-pie-inconsistent-behavior-with-swipe-gesture.

In our app, we need to load fragments dynamically.

But since Method method = aClass.getMethod("setViewPagerObserver"); statement gives excepetion, and so that method.invoke(mAdapter, mObserver); mObserver is never set. Hence, if (N != mExpectedAdapterCount) and it will throw custom IllegalStateException.

A solution for above is to use registerDataSetObserver method, mAdapter.registerDataSetObserver(mObserver); and it works fine afterwards.

Question - 1) When exactly I should write registerDataSetObserver and unregisterDataSetObserver?

Question - 2) Why there are so many java.lang.NoSuchFieldException for each key like widthFactor, childIndex, needsMeasure etc.

chitrang200889 avatar Feb 20 '19 03:02 chitrang200889