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