How to show/ hide windowActionBar programatically in Android?
<p>I am applying one style to two activities. <code>MainActivity.java</code> has toolbar setup instead of action bar, therefore, I have following line in theme style to hide action bar:</p>

<pre><code>&lt;item name="windowActionBar"&gt;false&lt;/item&gt;
</code></pre>

<p>And in the another activity I have action bar enabled:</p>

<pre><code>final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
</code></pre>

<p>But this returns <strong>NOException</strong> error.</p>

<p>I tried following but didn't help either:</p>

<pre><code>actionBar.show();
</code></pre>

<p><strong>Style:</strong></p>

<pre><code>&lt;style name="BrownTheme" parent="Theme.AppCompat.Light.NoActionBar"&gt;
    &lt;item name="colorPrimary"&gt;@color/brown&lt;/item&gt;
    &lt;item name="colorPrimaryDark"&gt;@color/dark_brown&lt;/item&gt;
    &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
    &lt;item name="buttonStyle"&gt;@color/brown&lt;/item&gt;
    &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
    &lt;item name="windowNoTitle"&gt;true&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p><strong>Elaboration:</strong>
I am using style for two activities. The first activity has it's own toolbar instead of default action bar and the second activity has action bar. If I remove from style then I cannot run the first activity and if I put, then I cannot run the second activity. I want to enable it programatically in second activity.</p>

<p>Is there any possibility to change the style item attributes programatically? or any override method to bypass what I have in style item attributes?</p>