コード例 #1
0
 /**
  * onCreate
  *
  * <p>adds the preferences from the ressourcefile
  */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   addPreferencesFromResource(R.xml.preferences);
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
   prefs.registerOnSharedPreferenceChangeListener(this);
 }
コード例 #2
0
 /**
  * onCreateView
  *
  * <p>handles the special case of the serverport entry which is an int....
  */
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
   // prefs.registerOnSharedPreferenceChangeListener(this);
   for (String key : prefs.getAll().keySet()) {
     Preference pref = findPreference(key);
     if (pref == null) continue;
     if (key.equals("serverport")) pref.setSummary("" + prefs.getInt(key, 0));
     else pref.setSummary(prefs.getString(key, key));
   }
   return super.onCreateView(inflater, container, savedInstanceState);
 }