Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu)?

Explain difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu).

like image 413
Jumpo Avatar asked Dec 26 '12 16:12

Jumpo


1 Answers

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).

like image 65
Sam Avatar answered Sep 21 '22 18:09

Sam