/** * 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); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings_ui_fragment); final PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("ui.storage"); final Preference button_f = (Preference) getPreferenceManager().findPreference("ui.rescan"); if (button_f != null) { button_f.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { MainActivity.fullStorageScan(); preferenceCategory.removePreference(button_f); return true; } }); } final Preference button_u = (Preference) getPreferenceManager().findPreference("ui.clear_unavailable"); if (button_u != null) { button_u.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { IndexingDB iDB = new IndexingDB(getActivity()); List<GameInfoStruct> games = iDB.getIndexGISList(MainActivity.SORT_NONE); iDB.close(); for (GameInfoStruct game : games) { if (!game.getFile().exists()) { game.removeIndex(getActivity()); } } MainActivity.prepareFileListView(false); preferenceCategory.removePreference(button_u); return true; } }); } final Preference button_c = (Preference) getPreferenceManager().findPreference("ui.clearcache"); if (button_c != null) { button_c.setOnPreferenceClickListener( new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { MainActivity.clearCache(); preferenceCategory.removePreference(button_c); return true; } }); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings_emu_fragment); PreferenceGroup prefGroup = getPreferenceScreen(); for (int i = 0; i < prefGroup.getPreferenceCount(); i++) { Preference pref = prefGroup.getPreference(i); if (pref instanceof CheckBoxPreference) { CheckBoxPreference checkBoxPref = (CheckBoxPreference) pref; checkBoxPref.setChecked(SettingsManager.getPreferenceBoolean(checkBoxPref.getKey())); } } }