java.lang.IllegalStateException:必须在主题中指定preferenceTheme [英] java.lang.IllegalStateException: Must specify preferenceTheme in theme
问题描述
我试图在运行于API 16的应用程序中加载PreferenceFragment(PreferenceFragmentCompat),但是每次尝试加载该片段时,都会出现以下错误:
I am trying to load a PreferenceFragment (PreferenceFragmentCompat) in an application running on API 16, but every time I attempt to load the fragment I get the following error:
E/AndroidRuntime:致命例外:main java.lang.IllegalStateException:必须在主题中指定preferenceTheme
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalStateException: Must specify preferenceTheme in theme
该片段在API级别21及更高版本中加载得很好.我尝试使用此库 https://github.com/Gericop/Android-Support-Preference-V7-Fix ,但仍无法正常工作.
The fragment loads just fine in API levels 21 and up. I've tried using this library https://github.com/Gericop/Android-Support-Preference-V7-Fix, but it's still not working.
推荐答案
我设法修复了它.问题是我的活动正在加载片段,但没有设置主题.
I managed to fix it. The problem was my activity that was loading the fragment didn't have the theme set.
< activity android:name =.controllers.MainActivity"android:theme ="@ style/AppTheme.Base"/>
这篇关于java.lang.IllegalStateException:必须在主题中指定preferenceTheme的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!