UTILIZING THE ACTION BAR
Besides fragments, another new feature introduced in Android 3.0 is the Action Bar. In place of the traditional title bar located at the top of the device’s screen, the Action Bar displays the application icon together with the activity title. Optionally, on the right side of the Action Bar are action items. Figure 2-14 shows the built-in Email application displaying the application icon, activity title, and some action items in the Action Bar. The next section discusses action items in more details.
The following Try It Out shows how you can programmatically hide or display the Action Bar.
TRY IT OUT: Showing and Hiding the Action Bar
1. Using Eclipse, create a new Android project and name it MyActionBar.
2. Press F11 to debug the application on the Android emulator. You should see the application and its Action Bar located at the top of the screen (containing the application icon and the application name “MyActionBar”; see Figure 2-15).
3. To hide the Action Bar, add the following line in bold to the AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.learn2develop.MyActionBar"
android:versionCode="1"
android:versionName="1.0">Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access