Setting menus in OnCreateOptionsMenu()

The OnCreateOptionsMenu() method is called to give an opportunity to the Activity parameter to define actions for the ActionBar. The Activity class provides a MenuInflater method, which reads the XML definition file and places the action defined on the ActionBar. The following code shows the implementation from the code bundle:

public override bool OnCreateOptionsMenu(IMenu menu)
{
    MenuInflater.Inflate(Resource.Menu.POIListViewMenu, menu);
    return base.OnCreateOptionsMenu(menu);
}

Get Xamarin Mobile Application Development for Android - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.