Reputation: 271
I'm currently working on a mp3 library on Android. Thing is, there are 4 tab, representing Songs, Albums, Artists and Playlists. My main activity creates a tabspec for each tab and add them to a tabhost. The problem is, I can't use the ActionBar. I tried the tutorial from Android Developpers and it works fine, however when I try to apply it on my project it doesn't work. I can't see the actionbar and if I try a getActionBar() in my activity it returns null.
As in the tutorial I put this code in the activity :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionbar_menu, menu);
return true;
}
And I created this menu :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_save"
android:title="Hello !"
android:showAsAction="ifRoom" />
</menu>
I suppose there are more things to do in order to display the actionbar, yet I can't find an accurate on the Web since now ... Does this have something to do with the xml from my main activity ?
Thanks for your attention
Upvotes: 1
Views: 2429
Reputation: 6090
For me I added this to my manifest:
android:theme="@android:style/Theme.Holo.Light.DarkActionBar" >
Hopefully that saves some time from having to look it up.
Upvotes: 5
Reputation: 81409
The action bar is only available from Android 3.0 and above, and you need to set your application theme to Holo.
Besides setting the sdk version, for instance:
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="15"/>
You also have to make the application theme use Holo.
Upvotes: 3