0

I'm using a ViewPager to slide across 3 screens at the moment, which is initialised in a FragmentActivity.

My aim is to have a Toolbar or ActionBar that remains the same for each page in the ViewPager - apart from the title, which changes depending on the page you are on.

Does anybody know how I can achieve this?

I have tried the following

mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(mActionBarToolbar);
getActionBar().setTitle(mViewPager.getCurrentItem()); 

But I keep getting an error setActionBar (android.widget.Toolbar) in Activity cannot be applied to android.widget.support.v7.Toolbar.

Any ideas?

iLearnAndr0id
  • 41
  • 1
  • 5

1 Answers1

0

When using the support libraries, you need to use the support methods.

mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mActionToolbar);
getSupportActionBar().setTitle(mViewPager.getCurrentItem());

You should be golden if you replace your code to the code above.

Glo
  • 161
  • 1
  • 6