Click here to Skip to main content
15,885,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create an app in android api 10(2.3.5) c#.
I use xml file MainMenu for menu. I use this code for creating menu:

public bool onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(Resource.Layout.MainMenu, menu);
return true;
}


But I get error getMenuInflater does not exists in the current context

please tell me what is the problem.
Posted
Comments
Baburc 20-Aug-14 1:52am    
Sorry I tried MenuInflater inflater = getActivity().getMenuInflater();
but same error

Try changing this line to
Java
MenuInflater inflater = getMenuInflater();

to
Java
MenuInflater inflater = getActivity().getMenuInflater();

i hope you have created your menu inside
Java
<menu></menu>
tags correctly. if not Refer this tutorial Menus
 
Share this answer
 
public override bool OnPrepareOptionsMenu
(IMenu menu)
{
this.MenuInflater.Inflate (Resource.Layout.MainMenu, menu);
return base.OnPrepareOptionsMenu (menu);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900