質問

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