Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add the category on preference header?

I have a simple preference_headers.xml file. I want to add some categories on my preference headers. I have tried to implement <PreferenceCategory /> in my preference_headers.xml, but it doesn't work. I'm using API level 11. As shown in the figure below, Android Developers from official website can add the categories. How can I add it too?

categories on preference header

And here is a few of my preference_headers.xml code. It won't work:

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

Thanks for your help.

like image 912
Anggrayudi H Avatar asked Oct 10 '14 11:10

Anggrayudi H


1 Answers

It's been close to a year since this was asked but I run into this example at http://www.101apps.co.za/articles/preference-settings.html that I think describes the requirement of the question in great detail and explanation.

I hope that it will help someone as it has helped me since it details the process of building a preference screen with categories and headers on the same page!

Cheers.

like image 109
gnl Avatar answered Nov 01 '22 18:11

gnl