Reputation: 41
I'm trying to make an app that disables the user from going to the menu. I know I have to override onPrepareOptionsMenu(Menu menu) but what do I have to put as input for menu if I want to use this function in a different function? I don't quite understand the Menu object and how many types it has.
Upvotes: 0
Views: 37
Reputation: 2696
Do something like this:
private Menu mOptionsMenu;
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
mOptionsMenu = menu
...
}
private void updateOptionsMenu() {
if (mOptionsMenu != null) {
onPrepareOptionsMenu(mOptionsMenu);
}
}
and then call the updateOptionsMenu() function where you want
Upvotes: 1