I’m trying to use the MenuInflater to create a menu in MonoDroid but i keep getting
“Could not find schema information for ‘menu’
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/Search"
android:title="@string/Search"
android:icon="@drawable/ic_menu_search_holo_light"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/AddProduct"
android:title="@string/AddProduct"
android:icon="@drawable/ic_menu_add"
android:showAsAction="ifRoom"
/>
</menu>
The Resource.designer.cs doesn’t include menu, and I’ve tried to fix it by changing to AndroidResource, and rebuild.
MenuInflater code.
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//Use UI created in Main.axml
SetContentView(Resource.Layout.Main);
var AddNewProduct = FindViewById<Button>(Resource.Id.AddNewProduct);
AddNewProduct.Click += (sender, e) =>
{
StartActivity(typeof(AddProduct));
};
}
public override void OnCreateOptionsMenu(IMenu menu)
{
MenuInflater menuInfalter = MenuInflater;
menuInfalter.Inflate(Resource.Menu.MainMenu, menu);
base.OnCreateOptionsMenu(menu);
}
I know there is plenty bad code. but i just need to know how to add my menu xml to Resource.designer.cs?
Add your Menu directory and any resources files through MonoDevelop or Visual Studio. That way they will be added to the csproj and packaged during the build process. Just adding files to directories does not include them in the build.