分享活动和MapActivity之间的选项菜单选项、菜单、MapActivity

2023-09-05 11:23:44 作者:我以为我可以

分享活动和MapActivity之间的一个选项菜单。 这可能吗?

Sharing an Options Menu between Activity and MapActivity. Is this possible?

我有一个选项菜单多种活动之间共享,但现在我需要在一个MapActivity该菜单。

I have an Options Menu shared between multiple Activities but now I need that menu in a MapActivity.

推荐答案

定义XML中的菜单。把智慧来加载XML的静态方法,然后调用从 onCreateOptionsMenu这个方法()在各个类。放入另一个静态方法的智慧为 onOptionsItemSelected(),并呼吁从 onOptionsItemSelected这个方法()在各个类

Define the menu in XML. Put the smarts to load that XML in a static method, then call that method from onCreateOptionsMenu() in your various classes. Put the smarts for onOptionsItemSelected() in another static method, and call that method from onOptionsItemSelected() in your various classes.