Setting Background Colour to PreferenceActivity
<p>I am having a confusion regarding setting of a background colour in my preference activity. My settingsactivity doen't have any layout.xml attached with it and thus generated everything from the headers.xml and preferences.xml. I used <a href="https://stackoverflow.com/a/8961125/5863472">this</a> answer in my onCreate method of my settingsactivity class.</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setupActionBar();
    this.getWindow().getDecorView().setBackgroundColor(0xFF111321);
}
</code></pre>
<p>Using this I can see the change in my <a href="https://i.stack.imgur.com/B2Ewf.png" rel="nofollow noreferrer">preferences</a> (sorry for the colour) but my <a href="https://i.stack.imgur.com/6qyVu.png" rel="nofollow noreferrer">headers</a> headers stay the same. To change the background of my headers I have to write:</p>
<pre><code> @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setupActionBar();
    this.getWindow().getDecorView().setBackgroundColor(0xFF111321);
    listView = getListView();
    listView.setBackgroundColor(0xFF111321);
}
</code></pre>
<p>Also if I don't use <code>getWindow()</code> the opposite happens.</p>
<p>Why is this happening?
I hate writing duplicate code for the same functionality, is there any way to do the requirement with a single code.</p>
<p>N.B. <code>getWindow()</code> also works with my other activities.</p>