@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getFragmentManager().beginTransaction() .replace(android.R.id.content, new PrefsFragment()).commit(); setupActionBar(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); //setHasOptionsMenu(true); setUpUnitTypePrefs(); // Bind the summaries of EditText/List/Dialog/Ringtone preferences // to their values. When their values change, their summaries are // updated to reflect the new value, per the Android Design // guidelines. // bindPreferenceSummaryToValue(findPreference("example_text")); // bindPreferenceSummaryToValue(findPreference("example_list")); }
/** * Helper Class to setup the default Unit Type preference list in code */ private void setUpUnitTypePrefs() { PreferenceScreen screen = getPreferenceScreen(); MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity()); listPref.setOrder(0); listPref.setDialogTitle(R.string.unit_select_title); listPref.setKey(UNIT_TYPE_PREF_KEY); listPref.setSummary(R.string.unit_select_summary); listPref.setTitle(R.string.unit_select_title); listPref.setEntries(getUnitTypeNameArray(getResources())); String[] keyArray = getUnitTypeKeyArray(getResources()); listPref.setEntryValues(keyArray); final Set<String> result = new HashSet<>(); Collections.addAll(result, keyArray); listPref.setDefaultValue(result); screen.addPreference(listPref); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); ViewUtils.toast("other", getActivity()); if (id == android.R.id.home){ ViewUtils.toast("Home", getActivity()); startActivity(new Intent(getActivity(), SettingsActivity.class)); return true; } return super.onOptionsItemSelected(item); } }