سؤال

I'm using the AppCompat/ActionBarCompat library and I need to create a custom ActionBar. I need to open the activity without an ActionBar and enable it only when I add the custom view. How can I do this?

PS: I need to define the activity to not use an ActionBar through the AndroidManifest.xml and my application minimum API level is 10.

هل كانت مفيدة؟

المحلول

.hide() the action bar and then .show() the action bar when your ready for it

import android.support.v7.app.ActionBar;

...

private ActionBar mActionbar;

...

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mActionbar = getSupportActionBar();
    mActionbar.hide()
}

... somewhere when something cool happens

mActionbar.show();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top