Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android (3.0) Action Bar dont want to Go

I am working with XOOM and trying to hide action bar. So i follow the instruction did the following in manifest file:

uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11"

also set activity theme.

android:theme="@android:style/Theme.Holo.NoActionBar"

unfortunately i can still see the action bar. so i remove the holo action part from my manifest and added following code

ActionBar actionBar = getActionBar(); actionBar.hide();

getting null pointer exception from hide() method. so i understand getActionBar() is returning null. Now i am curious what i am missing?

like image 756
minhaz Avatar asked May 06 '11 17:05

minhaz


Video Answer


2 Answers

Theme.Holo.NoActionBar isn't public in the framework- Instead, you can declare your own style like this:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
</style>
like image 193
Alexander Lucas Avatar answered Oct 24 '22 00:10

Alexander Lucas


I came to exactly the same conclusion. If you can't make the ActionBar show on the screen it is most likely either :

  • window has no title; ActionBar is essentially a glorified title bar, thus no title= no ActionBar, although this is nowhere mentioned in the docs

  • you tried to call the getActionBar() method prior setting the content view in the activity. In this case, this method returns null. Again, nowhere mentioned in the docs, and if you try to construct/modify the ActionBar as a part of the custom view constructor, you are out of luck.

More about my explorations of ActionBar in Honeycomb can be found on my blog here

like image 38
2 revs, 2 users 84% Avatar answered Oct 24 '22 00:10

2 revs, 2 users 84%