Alex Rivera | Logout

How to hide action bar before activity is created, and then show it again?

Asked 2011-12-14T06:24:38.790
247

I need to implement splash screen in my honeycomb app. I use this code in activity's onCreate to show splash:

setContentView(R.layout.splash);
getActionBar().hide();

and this code to show main UI after sometime:

setContentView(R.layout.main);
getActionBar().show();

But before onCreate is called and splash appears, there is small amount of time when action bar shown.

How can I make action bar invisible?

I tried to apply theme to activity without action bar:

<item name="android:windowActionBar">false</item>

but in that case getActionBar() always returns null and I found no way to show it again.

Edit
Report

2 Answers

37

If you are using ActionBarSherlock, then use Theme.Sherlock.NoActionBar Theme in your Activity

<activity 
    android:name=".SplashScreenActivity"
    android:theme="@style/Theme.Sherlock.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
answered 2013-02-06T22:18:09.663
4

For Splashscreen you should use this line in manifest and don't use getActionBar()

<item name="android:windowActionBar">false</item>

and once when Splash Activity is finished in the main Activity use below or nothing

<item name="android:windowActionBar">true</item>
answered 2011-12-14T06:29:23.113

Your Answer