如果之前有人问过这个问题,我很抱歉...... 好吧,正如标题所问, onCreateOptionsMenu 什么时候执行?在 onResume 之前还是之后?
在我的应用中, 当 Activity 首次运行/打开时,顺序将是 onCreate --> onResume --> onCreateOptionsMenu
但是如果我改变设备的方向,它会自动调用 onDestroy,因此 Activity 将被重新创建,在这种情况下,顺序将是 onCreate --> onCreateOptionsMenu --> onResume
我现在很困惑...有人可以对此给出解释吗?
最佳答案
您可以阅读 onCreateOptionsMenu this :
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).
关于android - onCreate、onCreateOptionsMenu、onResume,执行顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18955380/