Android Studio 1.4
I have a toolbar that I am inflating in my activity_main.xml . I have a menu called main.xml that is pumping up and there is only 1 icon on it.
When the user clicks to open the fragment. I have another friends.xml menu that has 2 icons.
When I inflate the friends menu in the fragment, it still displays the icon in the main.xml menu.
I thought that inflating a new menu on the toolbar would delete the existing menu.
This is a screenshot of the main.xml menu. A search icon is displayed. 
This is a screenshot of a snippet since you see that the find icon still exists.
activity_main.xml with toolbar enabled
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" xmlns:app="http://schemas.android.com/apk/res-auto"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/tbMain" layout="@layout/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true"/> </LinearLayout> </android.support.v4.widget.DrawerLayout>
here is my code for creating a menu in MainActivity.java
private void setupToolBar() { mToolbar = (Toolbar)findViewById(R.id.tbMain); setSupportActionBar(mToolbar); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); }
And in my fragment I have this, as you can see that I am inflating the friends.xml menu.
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.friends, menu); }
Thanks so much for any suggestions,