Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
If you changed your apps style to not have the actionbar and you are setting a custom toolbar(through
setSupportActionBar()), then you should be using
getSupportActionBar() or your custom toolbar reference everytime you want to interact with it.
If you are using AppCompat that you have to always use
getSupportActionBar() and you also have to use it if the API level is lower than 11.