我想为 Android 制作 Option Menu
,我访问过这个网站。在他们的脚本中,我找到了 onPrepareOptionsMenu
,我尝试使用带有和不带有 onPrepareOptionsMenu
的 Android 2.3.3 编译器进行编译和运行,两者都有效,但我没有看到任何区别.
public boolean onCreateOptionsMenu(Menu menu){
//code here
}
public boolean onOptionsItemSelected(MenuItem item){
//code here
}
public boolean onPrepareOptionsMenu(Menu menu){
//code here
}
onPrepareOptionsMenu
方法实际上是做什么的?那个方法重要吗?我可以删除该方法吗?
加法
哦,我也听说过 Android 3.0 中的 Action Bar
,它说 Action Bar 是 make Option Menu
的替代方式,它使用 onPrepareOptionsMenu
。对吗?
谢谢...
最佳答案
查看API :
Prepare the Screen's standard options menu to be displayed. This is called right before the menu is shown, every time it is shown. You can use this method to efficiently enable/disable items or otherwise dynamically modify the contents.
关于android - onPrepareOptionsMenu 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16758517/