I have added a menu in my fragment and would like to display menu items in the toolbar.
the menu xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_note"
        android:icon="@drawable/ic_more_24dp"
        app:showAsAction="always"
        android:visible="true"
        android:orderInCategory="1"
        android:title="Note"/>
    <item
        android:id="@+id/action_submit"
        android:icon="@drawable/ic_more_24dp"
        app:showAsAction="always"
        android:orderInCategory="2"
        android:title="Submit"/>
</menu>
The view that holds the container, which holds the fragments is as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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=".DashboardActivity">
    <include layout="@layout/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </include>
    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_above="@+id/navigationView"
        android:layout_height="match_parent"
        android:layout_marginBottom="56dp"
        android:layout_marginTop="56dp"
       />
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigationView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:itemBackground="@android:color/white"
        app:itemIconTint="@color/cardview_dark_background"
        app:itemTextColor="@android:color/black"
        app:menu="@menu/navigation_menu"
        />
</android.support.constraint.ConstraintLayout>
The code to display the menu in the fragment is as follows:
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setHasOptionsMenu(true);
    init();
}
Then the code for the menu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_attendance, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
        case R.id.action_submit:
            return true;
        case R.id.action_note:
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
I have added the hasOptionMenu (true) and still the menu items will not display in the toolbar
 
     
    