Ошибка надувания класса <unknown> (PreferenceFragment)
У меня проблемы с добавлением PreferenceFragment
в моем приложении для Android. Когда я раздуваю PreferenceFragment
Я получаю следующую ошибку:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: be.nielsbril.bachelorproef.android.spotto, PID: 12652
android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.preference.Preference.onCreateView(Preference.java:522)
at android.preference.Preference.getView(Preference.java:498)
at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:246)
at android.widget.AbsListView.obtainView(AbsListView.java:2348)
at android.widget.ListView.onMeasure(ListView.java:1158)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18850)
at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1420)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:714)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:786)
at android.view.View.measure(View.java:18850)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:714)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1375)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:784)
at android.view.View.measure(View.java:18850)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1081)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18850)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2672)
at android.view.View.measure(Vi
Мой prefences.xml выглядит следующим образом:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:key="prefNotifications"
android:title="@string/pref_notifications"
android:summary="@string/pref_notifications_summary"
android:defaultValue="true" />
</PreferenceScreen>
Когда я раздуваю пустой PreferenceScreen
это работает, когда SwitchPreference
там это не так.
Я понятия не имею, что это может быть, возможно, небольшая ошибка, о которой я не знаю. Какие-либо предложения?