onPrepareOptionsMenu有什么作用?

编程入门 行业动态 更新时间:2024-10-27 01:29:31
本文介绍了onPrepareOptionsMenu有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想为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,它说操作栏是制作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 :

准备要显示的屏幕标准选项菜单.在显示菜单之前,每次显示菜单时都会调用此方法.您可以使用此方法有效地启用/禁用项目,或以其他方式动态地修改内容.

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.

更多推荐

onPrepareOptionsMenu有什么作用?

本文发布于:2023-10-07 17:19:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   作用   onPrepareOptionsMenu

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!