Explain difference between onCreateOptionsMenu(Menu menu)
and onPrepareOptionsMenu(Menu menu)
.
Asked
Active
Viewed 1.5k times
54

naXa stands with Ukraine
- 35,493
- 19
- 190
- 259

Jumpo
- 641
- 2
- 6
- 7
1 Answers
98
onCreateOptionsMenu()
is called once.
onPrepareOptionsMenu()
is called every time the menu opens.
From the onCreateOptionsMenu()
documentation:
This is only called once, the first time the options menu is displayed. To update the menu every time it is displayed, see
onPrepareOptionsMenu(Menu)
.

Sam
- 86,580
- 20
- 181
- 179
-
24Also of note, use `invalidateOptionsMenu()` to force a reload of `onPrepareOptionsMenu(Menu)`. – Joshua Pinter Mar 16 '14 at 23:33