The onCreateOptionsMenu method in the android.app.Activity class is used to inflate the menu resource for an Activity. The method is called during the creation of the Activity's options menu, which can be accessed through the overflow menu icon or the device's hardware menu button.
Here are some code examples:
Example 1:
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; }
In this example, the onCreateOptionsMenu method inflates the main menu resource and adds items to the action bar if it is present.
In this example, the onCreateOptionsMenu method inflates the main menu resource and retrieves the search view item from the menu. The method then returns true to indicate that the menu is created successfully.
The package library for the onCreateOptionsMenu method is the android.app package.
Java Activity.onCreateOptionsMenu - 30 examples found. These are the top rated real world Java examples of android.app.Activity.onCreateOptionsMenu extracted from open source projects. You can rate examples to help us improve the quality of examples.