PagerSlidingTabStrip
PagerSlidingTabStrip copied to clipboard
Crash when the FragmentPagerAdapter's data changes
I created a repo that has a simple project to reproduce the bug https://github.com/adi1133/PageSlidingTabStripBug
Click the Add Fragment button and go past the last fragment, the app will crash.
I made a branch that shows how I fixed the problem in my project https://github.com/adi1133/PageSlidingTabStripBug/tree/bug_fixed
PagerSlidingTabStrip::notifyDataSetChanged is not called when the adapter of the PageView changes content, so I call it manually when needed
I am seeing this same issue, and this fix resolved part of it for me. An NPE still occurs if a tab you are on is removed. The tabs are out of sync with the adapter at that time, so the call to onPageScrolled throws an NPE because tabsContainer has no child views.
scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()));
The PagerSlidingTabStrip already has a reference to the ViewPager. I'll look to see if it can hook into its notifyDataSetChanged when it is set using setViewPager(...).
how can I update the contents of the tab strip at run time. notifyDataSetChanged does not work. MyPagerAdapter never rerun getItem