PagerSlidingTabStrip icon indicating copy to clipboard operation
PagerSlidingTabStrip copied to clipboard

Crash when the FragmentPagerAdapter's data changes

Open adipascu opened this issue 11 years ago • 3 comments

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.

adipascu avatar Jan 31 '14 16:01 adipascu

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

adipascu avatar Jan 31 '14 17:01 adipascu

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(...).

austynmahoney avatar Mar 05 '14 18:03 austynmahoney

how can I update the contents of the tab strip at run time. notifyDataSetChanged does not work. MyPagerAdapter never rerun getItem

mariobuc avatar Dec 10 '17 01:12 mariobuc