Reputation: 833
Im my application I inflate different menu resources, like this:
public boolean onCreateOptionsMenu(Menu menu) {
_menu = menu;
if (/* CONDITION */) {
getMenuInflater().inflate(R.menu.menu_activity_detail, _menu);
} else {
getMenuInflater().inflate(R.menu.menu_empty, _menu);
}
return true;
}
before this I save the Menu
object for further reuse, like inflating a new menu under specific circumstances.
Now the question: is there any way to know which resource I've inflated at the creation of my activity, without manually saving the id of R.menu.menu_res
?
Upvotes: 0
Views: 248
Reputation: 5773
You should not keep a reference to the menu. Why don't you use the invalidateOptionsMenu() method of your Activity? There's the supportInvalidateOptionsMenu() to handle AppCompatActivity
Upvotes: 1