I have an activity that extends PreferenceActivity.
My theme : android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" is applied to the application level in the Manifest file.
Everything is getting the desired theme except the "PreferenceScreen" elements of "PreferenceCategory". They are still having the default black background. In simple words, the main Preference Category screen which has the parent Preference Screens are getting the theme but if I click on any of the PreferenceScreens to go to their element preferences(EditText etc etc), they are not getting the theme...
Any Idea why this might be happening?
The structure or preferences.xml is something like this :
<PreferenceCategory>
<PreferenceScreen>
<EditTextPreference>
...
</EditTextPreference>
<EditTextPreference>
...
</EditTextPreference>
...
</PreferenceScreen>
<PreferenceScreen>
...
</PreferenceScreen>
</PreferenceCategory>
At last i found out how to change theme of "PreferenceActivity" programmatically(via java code)
To change theme just do like this:
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.Holo_Theme_Light);
super.onCreate(savedInstanceState);
}
Always call setTheme(R.style.yourtheme);
method before super.onCreate(savedInstanceState);
method. By doing this it will produce result as shown below.
That's all.
If yo call setTheme(R.style.yourtheme);
method after super.onCreate(savedInstanceState);
method it will produce result as shown below.
Note: Themes are not recognize by nested PreferenceScreen. To apply theme to that nested PreferenceScreen you have to make an another PreferenceActivity for that nested PreferenceScreen and call setTheme(R.style.yourtheme);
method there.