Back to project page android-sholi.
The source code is released under:
GNU General Public License
If you think the Android project android-sholi listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * ShoLi, a simple tool to produce short (shopping) lists. *//from ww w. j av a 2 s. c om * Copyright (C) 2014 David Soulayrol * * ShoLi is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ShoLi is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package name.soulayrol.rhaa.sholi; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.ListPreference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false); } @Override public void onResume() { super.onResume(); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); updatePreferenceSummary(sharedPreferences, SettingsActivity.KEY_CHECKING_FLING_LEFT_ACTION); updatePreferenceSummary(sharedPreferences, SettingsActivity.KEY_CHECKING_FLING_RIGHT_ACTION); updatePreferenceSummary(sharedPreferences, SettingsActivity.KEY_LIST_ITEM_SIZE); updatePreferenceSummary(sharedPreferences, SettingsActivity.KEY_IMPORT_MERGE_POLICY); } @Override public void onPause() { super.onPause(); getPreferenceScreen().getSharedPreferences() .unregisterOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (SettingsActivity.isListPreference(key)) updatePreferenceSummary(sharedPreferences, key); } private void updatePreferenceSummary(SharedPreferences sharedPreferences, String key) { ListPreference p = (ListPreference) findPreference(key); p.setSummary(p.getEntry()); } }