What is onCreateOptionsMenu(Menu menu)

前端 未结 4 1028
太阳男子
太阳男子 2020-12-29 08:23

What are the two parameters Menu and menu in method onCreateOptionsMenu(Menu menu) and how to use this method. I have another question why this pa

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 08:57

    First of all in onCreateOptionsMenu(Menu menu) function you passing only one parameter not two. You passing object of menu class there. We using this function to override the default function to customize our own menu like adding buttons and texts, images etc., in menu.

    For more reference

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.game_menu, menu);
        return true;
    }
    

提交回复
热议问题