Magnus
Magnus

Reputation: 18748

Refresh titles of a PagerTabStrip immediately?

I have a PagerTabStrip with two tabs, all is working fine. But when the user performs a certain task in the app, I need to make it refresh the titles of the tabs (at least one of them) immediately without waiting for it to call getPageTitle(). How can I do this?

When I used an ActionBar with tabs, I used this code to update the second tab:

getSupportActionBar().getTabAt(1).setText( mSectionsPagerAdapter.getPageTitle(1) );

What I need is a replacement for this, but using the PagerTabStrip.


EDIT

It seems like the following might be working:

mSectionsPagerAdapter.notifyDataSetChanged();

Other solutions are still welcome!

Upvotes: 0

Views: 522

Answers (1)

Gabriel Pereira
Gabriel Pereira

Reputation: 580

It should be the issue of PagerTabStrip https://code.google.com/p/android/issues/detail?id=183127

Try this ugly workarround

viewPager.post(new Runnable() {
            @Override
            public void run() {
                viewPager.setCurrentItem(1);
                viewPager.setCurrentItem(0);
            }
        });

Upvotes: 0

Related Questions