Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android- hide actionbar during startup and then show it again?

My android app has tab navigation using an action bar. It works well, but it bothers me that during the first boot of the app, a small default action bar briefly shows up before being replaced by the real, tab-navigation action bar. My onCreate starts like this:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_main);

    //Set up the actionbar
    final ActionBar actionBar = getActionBar();
.
.
.

What do I have to do so that the real actionbar will be initialized without a small default one briefly showing before it does on startup?

Thanks

like image 974
LoneDuck Avatar asked Sep 18 '12 02:09

LoneDuck


People also ask

How do you display action bar back button on all versions of Android?

Show back button using actionBar. setDisplayHomeAsUpEnabled(true) this will enable the back button. Custom the back event at onOptionsItemSelected. This will enable the back function to the button on the press.


1 Answers

Hide during startup

 getSupportActionBar().hide();

After you can show it again with ...

 getSupportActionBar().show();

It should be the same with native ActionBar of Android.

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

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

and once it's finished in the main Activity use below or nothing

<item name="android:windowActionBar">true</item>
like image 85
MBMJ Avatar answered Sep 30 '22 15:09

MBMJ