/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } }
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); } }
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { // COMPLETED (3) Don't forget to add code here to properly set the summary for an EditTextPreference if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (KEY_EXPORT_DATA_FORMAT_LIST.equals(key)) { listPreference.setSummary("Current format is " + listPreference.getEntry().toString()); } } }
@Override public void onResume() { super.onResume(); listPreference.setSummary("Current format is " + listPreference.getEntry().toString()); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
@Override public void onResume() { super.onResume(); locationPreference.setChecked(sharedPref.getBoolean(KEY_INCLUDE_LOCATION, true)); updatePeriodPref.setSummary(updatePeriodPref.getText() + " ms"); highLimitPref.setSummary(highLimitPref.getText() + " atm"); sensorTypePreference.setSummary(sensorTypePreference.getEntry()); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
sensorTypePreference.setSummary(sensorTypePreference.getEntry()); break; default:
sensorTypePreference.setSummary(sensorTypePreference.getEntry()); break; default:
@Override public void onResume() { super.onResume(); locationPreference.setChecked(sharedPref.getBoolean(KEY_INCLUDE_LOCATION, true)); updatePeriodPref.setSummary(updatePeriodPref.getText() + " ms"); higLimitPref.setSummary(higLimitPref.getText() + " Lx"); sensorTypePreference.setSummary(sensorTypePreference.getEntry()); sensorGainPref.setSummary(sensorGainPref.getText()); getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { editor.putString("language", (String) newValue).commit(); languagePref.setSummary(entries[languagePref.findIndexOfValue( (String) newValue)]); Intent intent = new Intent(context, MainActivity.class); context.finish(); startActivity(intent); return true; } });
private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; int index = listPreference.findIndexOfValue(value); if (index >= 0) { listPreference.setSummary(listPreference.getEntries()[index]); } } }
private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } }
private void updateSummaries() { ListPreference pref = (ListPreference) findPreference("source_apple_2015"); pref.setSummary(pref.getEntry()); pref = (ListPreference) findPreference("source_apple_2017"); pref.setSummary(pref.getEntry()); pref = (ListPreference) findPreference("cache_size"); pref.setSummary(pref.getEntry()); }
public void onClick(DialogInterface dialog, int id) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor1 = settings.edit(); editor1.putString("prefKMLAltitudeMode", "0"); editor1.commit(); ListPreference pKMLAltitudeMode = (ListPreference) findPreference("prefKMLAltitudeMode"); pKMLAltitudeMode.setValue("0"); pKMLAltitudeMode.setSummary(R.string.pref_KML_altitude_mode_absolute); } });
private void setActionType(String newValue) { final ListPreference action_list = (ListPreference) findPreference("ba_action_list"); if (newValue != null && !newValue.isEmpty()) { int index = action_list.findIndexOfValue(newValue); action_list.setSummary(index >= 0 ? action_list.getEntries()[index] : null); mActionBeacon.setActionType(ActionBeacon.ActionType.fromInt(index >= 0 ? index : 0)); } else { action_list.setSummary(action_list.getEntries()[0]); mActionBeacon.setActionType(ActionBeacon.ActionType.fromInt(0)); } }
protected void updateSketchbookDrivePref(ListPreference sketchbookDrive, Preference sketchbookLocation, ArrayList<APDE.StorageDrive> drives) { int selectedIndex = sketchbookDrive.findIndexOfValue(sketchbookDrive.getValue()); if (selectedIndex == -1) { //Uh-oh return; } APDE.StorageDrive selected = drives.get(selectedIndex); sketchbookLocation.setEnabled(!(selected.type.equals(APDE.StorageDrive.StorageDriveType.INTERNAL) || selected.type.equals(APDE.StorageDrive.StorageDriveType.SECONDARY_EXTERNAL))); sketchbookDrive.setSummary(selected.space + " " + selected.type.title); }
private void initWidgetPart(SharedPreferences sharedPreferences) { // widget icon style. ListPreference widgetIconStyle = (ListPreference) findPreference(getString(R.string.key_widget_icon_style)); widgetIconStyle.setSummary( ValueUtils.getIconStyle( getActivity(), sharedPreferences.getString(getString(R.string.key_widget_icon_style), "material"))); widgetIconStyle.setOnPreferenceChangeListener(this); }
private void initFilterPart(SharedPreferences sharedPreferences) { // default order. ListPreference defaultOrder = (ListPreference) findPreference(getString(R.string.key_default_photo_order)); String orderValue = sharedPreferences.getString(getString(R.string.key_default_photo_order), PhotoApi.ORDER_BY_LATEST); String orderName = ValueUtils.getOrderName(getActivity(), orderValue); defaultOrder.setSummary(getString(R.string.now) + " : " + orderName); defaultOrder.setOnPreferenceChangeListener(this); }
private void initThemePref(String theme) { ListPreference themePref = (ListPreference) findPreference(getString(R.string.pref_key_theme)); String theme_name = Settings.Utils.getThemeName(getActivity(), theme); themePref.setSummary(theme_name); themePref.setOnPreferenceChangeListener(this); }
private void initDownloadPart(SharedPreferences sharedPreferences) { // downloader. ListPreference downloader = (ListPreference) findPreference(getString(R.string.key_downloader)); String downloaderValue = sharedPreferences.getString(getString(R.string.key_downloader), "mysplash"); String downloaderName = ValueUtils.getDownloaderName(getActivity(), downloaderValue); downloader.setSummary(getString(R.string.now) + " : " + downloaderName); downloader.setOnPreferenceChangeListener(this); // download scale. ListPreference downloadScale = (ListPreference) findPreference(getString(R.string.key_download_scale)); String scaleValue = sharedPreferences.getString(getString(R.string.key_download_scale), "compact"); String scaleName = ValueUtils.getScaleName(getActivity(), scaleValue); downloadScale.setSummary(getString(R.string.now) + " : " + scaleName); downloadScale.setOnPreferenceChangeListener(this); }