I created an application in which I change a menu item, when I check, the application works with the changes. But when I restart the application, I lose the changes, although the file changed are present in internal storage.
i use the function public boolean onMenuOpened(int featureid, Menu menu) {}
to make the change. I would like to keep a part of the menu and to change the other.
Asked
Active
Viewed 50 times
0

diez
- 125
- 1
- 5
- 12
1 Answers
1
Menu changes aren't saved. You can use OnPrepareOptionsMenu to modify the menu based on some property.
public boolean onPrepareOptionsMenu (Menu menu) {
if(disableSomething) {
menu.findItem(R.id.someItemToDisable).setEnabled(false);
}
return true;
}

Robby Pond
- 73,164
- 16
- 126
- 119
-
That combined with SharedPreferences to save whichever options were selected – ElefantPhace Mar 25 '13 at 17:07
-
can you give me an example, please. – diez Mar 25 '13 at 17:15