PreferenceActivity and theme not applying

后端 未结 5 1544
不思量自难忘°
不思量自难忘° 2020-12-14 16:25

Hi all I have set the theme in the manifest file like this:

android:theme=\"@android:style/Theme.Light\"

But I have a problem in the Prefer

5条回答
  •  清歌不尽
    2020-12-14 17:09

    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.

    enter image description here

    That's all.

    If yo call setTheme(R.style.yourtheme); method after super.onCreate(savedInstanceState); method it will produce result as shown below.

    enter image description here

    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.

提交回复
热议问题