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
onCreateOptionsMenu
is called?onCreateOptionsMenu()
is called by the Android runtime when it need to create the option menu.
Android Developer Guide: Menus
If you've developed your application for Android 2.3.x and lower, the system calls onCreateOptionsMenu() to create the options menu when the user opens the menu for the first time. If you've developed for Android 3.0 and higher, the system calls onCreateOptionsMenu() when starting the activity, in order to show items to the app bar.
Please refer to other anwsers.
onCreateOptionsMenu
return Boolean
Activity.html#onCreateOptionsMenu
You must return true for the menu to be displayed; if you return false it will not be shown.
onOptionsItemSelected
return Boolean
When you successfully handle a menu item, return true. If you don't handle the menu item, you should call the superclass implementation of onOptionsItemSelected() (the default implementation returns false).