简体   繁体   English

如何延迟 onCreateOptionsMenu(Menu menu)?

[英]How do I delay onCreateOptionsMenu(Menu menu)?

Im a creating and options menu dynamically, the option menu depends on data that is created during the onCreate() stage.我是动态创建和选项菜单,选项菜单取决于在 onCreate() 阶段创建的数据。

The problem is that onCreateOptionsMenu() is called before the data is created.问题是在创建数据之前调用了 onCreateOptionsMenu()。 Is there a way to execute after onCreate()? onCreate()之后有没有办法执行?

Thanks Fabii谢谢法比

You can use invalidateOptionsMenu() , but it requires API level 11.您可以使用invalidateOptionsMenu() ,但它需要 API 级别 11。

Also, you can choose to override onPrepareOptionsMenu() instead, which will give you to opportunity to modify the menu before it is displayed each time.此外,您还可以选择重写onPrepareOptionsMenu() ,这样您就有机会在每次显示之前修改菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM