2016-11-21 1 views
0

환경 설정 목록과 함께 맞춤 레이아웃을 추가하고 싶습니다. 하지만 나 에게이 오류를 제공합니다.Android PreferenceFragmentCompat 맞춤 레이아웃 list_container 오류

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

스타일 :

<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> 

콘텐츠 는 뷰 그룹 클래스는

레이아웃 아니라고 id 속성 'android.R.id.list_container'로 볼 수있다

코드 :

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

    setPreferencesFromResource(R.xml.preferences, rootKey); 

} 

답변

1

지원 환경 설정 버전 24 이상을 사용하는 경우 Google은 R.id.list_container에서 android.R.id.list_container으로 필요한 ID를 변경했습니다.

그래서 단지에 레이아웃 파일을 변경합니다

<FrameLayout 
    android:id="@android:id/list_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
관련 문제