2014-10-10 3 views
12

간단한 preference_headers.xml 파일이 있습니다. 내 기본 설정 헤더에 몇 가지 범주를 추가하고 싶습니다. 내 preference_headers.xml<PreferenceCategory />을 구현하려고했지만 작동하지 않습니다. API 레벨 11을 사용하고 있습니다. 아래 그림과 같이 official website의 Android 개발자가 카테고리를 추가 할 수 있습니다. 어떻게 추가 할 수 있습니까? 여기 기본 설정 머리글에 범주를 추가하는 방법은 무엇입니까?

categories on preference header

그리고

preference_headers.xml 코드 몇입니다. 작동하지 않습니다 :

<preference-headers xmlns:android="http://schemas.android.com/apk/res/android"> 

    <PreferenceCategory android:title="ACCOUNT" > 

     <header android:fragment="com.example.preferenceheader.SettingsFragmentAccount" 
      android:title="@string/pref_header_category_account" 
      android:summary="@string/pref_header_summ_account" 
      android:icon="@drawable/ic_action_settings" /> 
    </PreferenceCategory> 

    <PreferenceCategory android:title="APPLICATION" > 

     <header android:fragment="com.example.preferenceheader.SettingsFragmentApplication" 
      android:title="@string/pref_header_category_application" 
      android:summary="@string/pref_header_summ_application" 
      android:icon="@drawable/ic_action_group" /> 
    </PreferenceCategory> 

</preference-headers> 

도움 주셔서 감사합니다.

+0

실제 환경 설정이 필요하지 않습니까? – Doomsknight

+0

실제 환경 설정이란 무엇입니까? 나는 이해하지 못한다. –

+0

체크 아웃 http://gmariotti.blogspot.in/2013/01/preferenceactivity-preferencefragment.html 그들은 훌륭하게 설명했습니다. –

답변

2

질문이 있은 지 1 년이 지났지 만,이 예제의 내용은 http://www.101apps.co.za/articles/preference-settings.html으로 실행됩니다. 질문의 요구 사항을 아주 자세하게 설명하고 있습니다.

같은 페이지에 카테고리와 헤더가있는 환경 설정 화면을 만드는 과정이 자세히 나와 있기 때문에 도움이되기를 바랍니다.

건배.

0

제목이있는 헤더를 추가해야합니다. 예 : AOSP 설정

<!-- WIRELESS and NETWORKS --> 
<header android:title="@string/header_category_wireless_networks" /> 

<!-- Wifi --> 
<header 
    android:id="@+id/wifi_settings" 
    android:fragment="com.android.settings.wifi.WifiSettings" 
    android:title="@string/wifi_settings_title" 
    android:icon="@drawable/ic_settings_wireless" /> 
+0

이것이 완전히 정확한지 확실하지 않습니다. 귀하의 응답에서 제안 된 하나의 제목이있는 머리글은 내가 시도 할 때 클릭 가능한 개별 머리글 항목이됩니다. 언급 할만한 가치가있는 것은'android.support.v14.preference.PreferenceFragment'를 사용하고 있는데, 신비한 방식으로 결과에 영향을 미칠 수 있습니다 ... – dbm

관련 문제