android actionbar - removing the actionbar dynamically

How about this?

public void hideActionBar(){
    getActionBar().hide();
}

Source: http://developer.android.com/guide/topics/ui/actionbar.html


Use this:

getActionBar().hide();

Android documentation for action bar hide method


If you want to actually remove the action bar (not create it in the first place) as opposed to create it but then just hiding it right away, you can do it via themes or via code.

Via theme or styled attributes:

Use one of the predefine system themes like Theme.Holo.NoActionBar or its variants. This is the easiest way to do it.

If you want to define using attributes inside your custom theme, then you could do this:

<resources>
    <style name="MyTheme" parent="some_parent_theme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>
        <item name="android:windowFullscreen">true</item>
    </style>
</resources>

Now add this theme to your activity or application.

Via code (make sure you call this before setContentView in Activity.onCreate):

requestWindowFeature(Window.FEATURE_NO_TITLE);