I want to set toolbar on my activity which extends FragmentActivity. I know that for use setSuppoertActionBar(toolbar)
method we e
You should extend your Activity from AppCompatActivity as this includes support for Fragments and the Toolbar. And then override the
onCreateOptionsMenu() and onOptionsItemSelected() methods
You shouldn't be overriding
onMenuItemSelected()
public class MainActivity extends AppCompatActivity { ...
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FragmentTransaction ft = getSupportFragmentManager.beginTransaction();
....
....
@Override
public boolean onCreateOptionsMenu(Menu menu) {
...
...
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
...
}