Adding Search icon when changed Fragment to Menu

I have a main activity in which you can change fragments, there is a menu with 2 icons which work fine, when i change to the next fragment i want a search icon to be added to the menu. I am new to android development and Xamarin. I have tried using OnPrepareOptionsMenu and OnCreateOptionsMenu in the fragment but am getting errors, here is the code.

    public virtual void OnPrepareOptionsMenu(IMenu menu){
        MenuInflater.Inflate (Resource.Menu.action_menu_search, menu);
        return base.OnCreateOptionsMenu (menu);

FindClubBar.OnPrepareOptionsMenu(IMenu)' hides inherited member 'Fragment.OnPrepareOptionsMenu(IMenu)'. To make the current member override that implementation, add the override keyword.

(I have tried adding override but it just causes more errors)

An object reference is required for the non-static field, method, or property 'MenuInflater.Inflate(int, IMenu)' (CS0120)

There is no argument given that corresponds to the required formal parameter 'inflater' of 'Fragment.OnCreateOptionsMenu(IMenu, MenuInflater)' (CS7036)

Thank you for your time

Sign In or Register to comment.