Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding actions to ActionBar


With Android 3.0 (Honeycomb, API level 11), Android introduced a uniform title, such as a widget that docks to the top of the screen, called ActionBar. It allows apps to add activity-specific actions to the top of the device screen, just below the status bar. We will define two actions for the POIListActivity class: New, to create a new POI, and Refresh, to refresh the cache of POIs from the device's local storage.

The Activity class provides the following virtual methods that can be overridden to add actions:

Virtual Method

Description

OnCreateOptionsMenu

It allows the creation of the actions either through API calls or through inflating an XML definition

OnOptionsItemSelected

It is called when an action in ActionBar is clicked