是什么在prepareOptionsMenu吗?prepareOptionsMenu

2023-09-05 05:49:23 作者:为谁画相思╮

我要让选项菜单为Android,我访问这个网站。在他们的剧本,我发现在prepareOptionsMenu ,我尝试编译和运行采用了Android 2.3.3编译器的使用和不使用在prepareOptionsMenu ,这两个作品,但我没有看到任何区别。

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
}

实际上什么是prepareOptionsMenu 的方法吗?那是方法重要吗?难道我只是删除方法?

What is actually onPrepareOptionsMenu method do? Is that method important? Could I just delete the method?

增加

呵呵,我也听到操作栏中的Andr​​oid 3.0,它说,操作栏是化妆的另一种方法选项菜单,并使用在prepareOptionsMenu 。是吗?

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:

prepare屏幕的标准选项菜单显示。这是它显示每次叫右侧的菜单显示之前。可以使用此方法来有效地启用/禁用的物品或其他动态修改的内容。

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.

相关推荐