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

最后都变了- 提交于 2019-12-03 05:25:35

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/14043631/what-is-the-difference-between-oncreateoptionsmenumenu-menu-and-onprepareoptio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!