问题描述
我想为Android制作Option Menu
,我访问了这个网站.在他们的脚本中,我找到了 onPrepareOptionsMenu
,我尝试使用带有和不带有 onPrepareOptionsMenu
的 Android 2.3.3 编译器编译和运行,两者都有效,但我没有看到任何区别.
I want to make Option Menu
for Android, I have visit this site. In their script, I found onPrepareOptionsMenu
, I try to compile and run using Android 2.3.3 compiler with and without onPrepareOptionsMenu
, both works, but I didn't see any difference.
public boolean onCreateOptionsMenu(Menu menu){
//code here
}
public boolean onOptionsItemSelected(MenuItem item){
//code here
}
public boolean onPrepareOptionsMenu(Menu menu){
//code here
}
onPrepareOptionsMenu
方法实际上是做什么的?这个方法重要吗?我可以删除该方法吗?
What is actually onPrepareOptionsMenu
method do? Is that method important? Could I just delete the method?
添加
哦,我也听说过 Android 3.0 中的 Action Bar
,它说 Action Bar 是 make Option Menu
的替代方式,它使用 onPrepareOptionsMenu.是吗?
Oh, I also hear about
Action Bar
in Android 3.0, it says that Action Bar is the alternative way for make Option Menu
, and it using onPrepareOptionsMenu
. Is that right?
谢谢...
推荐答案
查看API:
准备要显示的屏幕的标准选项菜单.这在菜单显示之前调用,每次显示.您可以使用此方法有效地启用/禁用项目或以其他方式动态修改内容.
这篇关于onPrepareOptionsMenu 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!