I have a ViewPager with FragmentPagerAdapter, which has 3 Fragments. Now, I have a number of items as part of the title of the fragment:
So user can add or remove those items, and title should update accordingly. However, this title seems static.
How can one recall this method to update FragmentPagerAdapter's titles?
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0: return items + " (" + notFoundItems + ")";
case 1: return found;
case 2: return review;
}
return "";
}
I found a couple of similar questions on SO, but I need to update title, not only the fragment itself.
Finally, I solved it by simply re-setting the pager.
private OrdersTabsAdapter tabsAdapter;
@InjectView(R.id.tabs_orders) SlidingTabLayout ordersTabs;
@InjectView(R.id.pager) ViewPager pager;
public void update() {
tabsAdapter.updateFragments(productId, status);
ordersTabs.setViewPager(pager); //this helped with the titles
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With