7

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?

minhaz
  • 4,233
  • 3
  • 33
  • 49

5 Answers5

19

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>
Alexander Lucas
  • 22,171
  • 3
  • 46
  • 43
  • I am trying to implement this method for action bar surpression, but i get an error when i try to set the parent to android:Theme.Holo.Light. I also tried @android:Theme.Holo.Light. Please help i've been banging my head against my keyboard trying to figure this one out. – aamiri May 08 '12 at 18:00
  • What error are you getting? And what platform versions are you getting it on? What devices are you testing with? – Alexander Lucas May 08 '12 at 21:00
  • I haven't gotten to the point of testing, i'm just trying to compile. My minSDK requirement in the manifest is api level 8, but my target api is 11. There are actually 2 errors that i get: error: "Error retrieving parent for item: No resource found that matches the given name '@android:Theme.Holo.Light'." and "Error: No resource found that matches the given name: attr 'android:windowActionBar'." – aamiri May 08 '12 at 21:12
  • The reason i am trying to do this is because i want to be able to highlight text in a webview in my app without giving the user the option to copy the text. I want to prevent the action bar that appears in ics from appearing when the user selects text. The app im working on has been supported all the way back to gingerbread and we want this feature that i am working on to work on older platforms as well as newer ones. – aamiri May 08 '12 at 21:18
  • 1
    Whoops, there was a small syntax error. Try @android:style/Theme.Holo.Light (fixed in post). Also, this won't exist for v8, only 11 and up, so make sure this style is only used where it exists. – Alexander Lucas May 08 '12 at 21:30
7

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

richq
  • 55,548
  • 20
  • 150
  • 144
Pavel Lahoda
  • 1,058
  • 10
  • 7
3

you can hide the action bar (which will display in the top of the screen). If your activity is tab activity then use the following line after the setcontentview line

getParent().getActionBar().hide(); 

If it is a normal activity then use

getActionBar().hide(); 

And setting on manifest is also working for me, but only to the particular activity you can set like this not to application.

android:theme="@android:style/Theme.Holo.NoActionBar"
Padma
  • 656
  • 3
  • 11
  • 30
2

this helped me.. edited values/styles.xml like this

<resources>

<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar" />

</resources>
Charan Pai
  • 2,288
  • 5
  • 32
  • 44
-8

The action bar in Honeycomb cannot be hidden because there are no physical buttons to back out of the app, so you could trap users in the app if the action bar is hidden. The best you can do is put the bar in "lights out" mode, where you get the small dots in place of the normal icons in the bar.

See this link: Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation

Community
  • 1
  • 1
Chris
  • 328
  • 2
  • 2
  • 1
    OP is referring to the action bar (runs along the top), which is seperate from the bar that runs along the bottom and includes back/home/etc – Alexander Lucas Jun 06 '11 at 22:57