Fragment Must specify preferenceTheme in theme onCreate

后端 未结 1 449
Happy的楠姐
Happy的楠姐 2021-01-01 19:44

I am trying to figure out why I am getting this error:

java.lang.IllegalStateException: Must specify preferenceTheme in theme
at android.support.v7.preferenc         


        
相关标签:
1条回答
  • 2021-01-01 20:32

    Thanks to the solution that @Panther suggested. All I had to do is to add this line <item name="preferenceTheme">@style/PreferenceThemeOverlay</item> to my Application Theme and not just the theme of the individual activity that is showing my PreferenceFragment like that:

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
    </style>
    

    Alternatively you can use

    <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>

    to achieve modern material look.

    0 讨论(0)
提交回复
热议问题