Forum Xamarin.Android

How do i create a menu fragment and add it to another menu

djRockStardjRockStar USMember
edited September 2016 in Xamarin.Android

I am using standalone toolbar (Appcompat library) to inflate the main_menu.xml.
main.menu.xml has a fragment in it call menu_fragment.xml.

However, I could not see the overflow bar. Any help ? Advanced Thanks.

main_menu.xml

                    <menu
                           <item
                            android:id="@+id/discard"
                            android:icon="@drawable/ic_discard"
                            android:orderInCategory="100"
                            android:title="@string/delete"
                            app:showAsAction="always"/>

                        <item
                            android:id="@+id/search"
                            android:icon="@drawable/ic_search"
                            android:orderInCategory="100"
                            android:title="@string/search"
                            app:showAsAction="always"/>

                    <fragment class ="mymenufragmentclass" />
                    </menu>

menu_fragment.xml

<menu
                    <item
                            android:id="@+id/settings"
                            android:orderInCategory="100"
                            android:title="@string/settings"
                            app:showAsAction="never"/>

                        <item
                            android:id="@+id/edit"
                            android:orderInCategory="100"
                            android:title="@string/edit"
                            app:showAsAction="never"/>

                        <item
                            android:id="@+id/Exit"
                            android:orderInCategory="100"
                            android:title="@string/exit"
                            app:showAsAction="never"/>
                    </menu>

FragmentClass

public class mymenufragmentclass : fragment
{
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                                return Inflater.Inflate(Resource.Menu.menu_fragment, container, false);
         }
 }

ActivityClass

[MainLauncher = true]
   Public Class mainActivity : ActionBarActivity
   {
         public OnCreateView()
         {
               // other stuff
               toolbar.Inflate(Resource.Menu.main_menu, ...)
          }
    }
Sign In or Register to comment.