onCreateOptionsMenu() calling super

前端 未结 2 1887
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 20:21

I\'m creating application with OptionsMenu. I found few examples with it, but everyone is using different place where to call super.onCreateOptionMenu

2条回答
  •  悲&欢浪女
    2020-12-23 21:10

    It depends on what you want to do. First example will place your menu and only your menu. Second one, will add first super class menu. Last one will add your menu first. But, keep in mind that menus also have an order field, which will be taken into account at render time.

    Let's say you are extending an activity that already has a menu, but you do not want that menu to appear but another one. In that case you would use first approach.

    Another example: you are extending an activity that has a menu, and you want to add another menu. In that case you could use either second or last approach.

提交回复
热议问题