DEPRECATED


PreferenceFragment is deprecated. You can try https://github.com/jenzz/Android-MaterialPreference https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary https://github.com/Gericop/Android-Support-Preference-V7-Fix https://github.com/michael-rapp/AndroidPreferenceActivity

Thanks for all your support!

Support PreferenceFragment


非官方PreferenceFragment兼容库,支持Android2.1及更高版本。

Unofficial PreferenceFragment compatibility layer for Android 2.1 and up.

About the status of the library

弥补官方没有PreferenceFragment兼容库

我会一直维护它的
I will always maintain its

计划支持 Android L Material Design
Plans to support Android L Material Design


Demo

二维码 Dimensional Code

Download Demo

Usage


Add the following config in your build.gradle:

dependencies {
   compile 'com.android.support:appcompat-v7:20.0.0'
   compile 'cn.kongnannan:preferencefragment:[email protected]'
}

Use it in your own code:

  import android.support.v4.preference.CheckBoxPreference;
  import android.support.v4.preference.EditTextPreference;
  import android.support.v4.preference.ListPreference;
  import android.support.v4.preference.PreferenceActivity;
  import android.support.v4.preference.PreferenceCategory;
  import android.support.v4.preference.PreferenceScreen;
  import android.support.v4.preference.SwitchPreference;
<PreferenceScreen xmlns:android1="http://schemas.android.com/apk/res/android"
    xmlns:android="http://schemas.android.com/apk/res-auto" >

    <PreferenceCategory
            android:title="@string/inline_preferences">

        <CheckBoxPreference
                android:key="checkbox_preference"
                android:title="@string/title_checkbox_preference"
                android:summary="@string/summary_checkbox_preference" />

        <SwitchPreference
                android:key="checkbox_preference"
                android:title="@string/title_switch_preference"
                android:summary="@string/summary_switch_preference" />

        <SwitchPreference
                android:key="checkbox_preference"
                android:title="@string/title_switch_preference"
                android:summary="@string/summary_switch_preference_yes_no"
                android:switchTextOn = "YES"
                android:switchTextOff = "NO"
                android:defaultValue="true" />

    </PreferenceCategory>

</PreferenceScreen>

Just extend PreferenceFragment and follow the Settings developer guide like if this layer wasn't even there to begin with.

http://developer.android.com/guide/topics/ui/settings.html

About me:

我来自孔孟之乡,六年代码生涯,略懂java、flex、php、javascript、html5、android等开发语言,热爱移动互联,目前从事Android开发

License

Copyright (c) 2014 Kong Nan

Licensed under the Apache License, Version 2.0

End

这是我自己APP的截图

alt tag