2016年1月23日 星期六

PreferenceFragment inAPI 10(can show the action bar)

must use

1.compile 'com.android.support:preference-v7:23.1.0'

2.create a class PreferencesFragment extends PreferenceFragmentCompat

3. set what the preference show

reference:http://pomprogrammer.blogspot.com/2015/12/setting.html



public void onCreatePreferences(Bundle bundle, String s) {
        addPreferencesFromResource(R.xml.preferences);
    }

4.specifiy the preferenceTheme in the AppTheme


<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">    <!-- Customize your theme here. -->    <item name="colorPrimary">@color/colorPrimary</item>    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>    <item name="colorAccent">@color/colorAccent</item>    <item name="preferenceTheme">@style/PreferenceThemeOverlay</item></style>