Reputation: 107
I have the following in my activity (sorry new to Java/Android):
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.selectItem:
// menu.add(...) --> how to get the menu instance?
return true;
default:
return super.onOptionsItemSelected(item);
}
}
I am wondering, how can I access a menu object in onOptionsItemSelected? For example, how would I go about adding a new view to the options menu based on the selection of an existing menu item? Is the answer related to "onPrepareOptionsMenu"?
Upvotes: 1
Views: 4789