I have a fragment in my Activity and the fragment has its own toolbar. Like this:
Here is the layout of the fragment:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hometsolutions.space.Fragments.ControlFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/Setup_next_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_setup_next"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toBottomOf="@+id/setup_next_recycler" />
</LinearLayout>
</FrameLayout>
I want to add menu on the Setup_next_toolbar. Not on the MainActivity toolBar.
I did this on the fragment:
on the onCreate
: setHasOptionsMenu(true);
then
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.Setup_next_menu, menu);
}
but it added the menu on the MainActivity tolbar. How can I set menuItems on the Setup_next_toolbar
?