I'm trying to follow Google's material design guidelines and therefore I would like to use the new Toolbar instead of the old ActionBar. But how do I set it in my Activity? The MainActivity has two screens that can be swiped left/right.
The setSupportActionBar method is not found and setActionBar requires a different version of the toolbar. Any idea?
package com.bla;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.bla.ui.TabsPagerAdapter;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// does not work WTF!
setSupportActionBar(toolbar);
ViewPager pager = (ViewPager)findViewById(R.id.pager_list_views);
TabsPagerAdapter pagerAdapter = new TabsPagerAdapter(getSupportFragmentManager(), this);
pager.setAdapter(pagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
tabLayout.setupWithViewPager(pager);
}
}