I am new to Android SDK (not java) and I had a question or two about options menus. I look around for several tutorials, including the developer.android one. My problem is the naming of files. The menu works fine when in my res/menu folder the menu xml document is titled menu.xml. If I try to call in mainMenu.xml I get a
mainMenu cannot be resolved or is not a field
error.
Here is the code in my main activity,
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainMenu, menu);
return true;
}
The “mainMenu” in R.menu.mainMenu in the above code is underlined in red (error)
So my question is can I name my menu file anything I want? This way seems to restrict me to one options menu per project which cannot be correct (unless I am missing something : )
You can definitely have multiple options menus: there may be a lower case restriction though. Use underscores and you should be all set?
EDIT: yep, this error message occurs when you try and build:
So there is a lower case restriction. Never knew that.