I'm trying to create a single menu
item. When I run my app, it crashes right when it starts up and I get the following error in LogCat:
E/AndroidRuntime(1507): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.menu" on path: /data/app/com.thing.appname-2.apk
Here is my XML:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/addEventMenu"
android:title="Add Event"
android:icon="@drawable/addeventimage"/>
</menu>
The following is outside of the onCreate method (don't know if it makes a difference):
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.addEventMenu:
//do something here when menu button is pressed
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(R.id.addEventMenu);
return super.onCreateOptionsMenu(menu);
}
I've also tried this and I get the same error:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}