2016-11-21 6 views
0

Ich möchte ein benutzerdefiniertes Layout mit Voreinstellungsliste hinzufügen. aber es gibt mir diesen Fehler.Android PreferenceFragmentCompat benutzerdefiniertes Layout list_container Fehler

Inhalt hat Ansicht mit id-Attribut 'android.R.id.list_container' dass ist kein Viewgroup Klasse

Layout:

<FrameLayout 
    android:id="@+id/list_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

Styles:

<style name="BestMainTheme" parent="Theme.AppCompat.NoActionBar"> 
    <item name="colorControlNormal">@color/white</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:windowBackground">@color/windowBackground</item> 
    <item name="preferenceTheme">@style/BestAppSettingsTheme</item> 
    <item name="android:textColorPrimary">@android:color/white</item> 
    <item name="android:textColorSecondary">@android:color/darker_gray</item> 
    <item name="android:textColorHint">@android:color/darker_gray</item> 
</style> 

<style name="BestAppSettingsTheme" parent="@style/PreferenceThemeOverlay.v14.Material"> 
    <item name="android:layout">@layout/fragment_preferences</item> 
</style> 

Code:

@Override 
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { 

    setPreferencesFromResource(R.xml.preferences, rootKey); 

} 

Antwort

1

Wenn Sie Support Preference Version 24 oder höher verwenden, hat Google die erforderliche ID von R.id.list_container in android.R.id.list_container geändert.

So ändern Sie einfach Ihr Layout-Datei:

<FrameLayout 
    android:id="@android:id/list_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
Verwandte Themen