Java 类android.support.v7.preference.ListPreference 实例源码

项目:GitHub    文件:SettingsFragment.java   
private void updateGridRecyclerLayoutSummary() {
  final ListPreference listPreference =
      (ListPreference) findPreference(Const.RECYCLER_LAYOUT_KEY);
  // We have to enable the Grid settings only if the selection is the related on
  final ListPreference gridPreference =
      (ListPreference) findPreference(Const.GRID_SPAN_COUNT_KEY);
  final String value = listPreference.getValue();
  final boolean gridGroupVisible = Const.GRID_RECYCLER_VIEW_LAYOUT_VALUE.equals(value);
  // We update summary
  if (gridGroupVisible) {
    final String spanCountValue = gridPreference.getValue();
    gridPreference.setSummary(
        getString(R.string.label_grid_recycler_span_count_summary, spanCountValue));
  }
  gridPreference.setVisible(gridGroupVisible);
}
项目:ubiquitous    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:Android_Sunshine_Watch    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android_nextgis_mobile    文件:SettingsFragment.java   
@Override
protected void createPreferences(PreferenceScreen screen)
{
    switch (mAction) {
        case SettingsConstantsUI.ACTION_PREFS_GENERAL:
            addPreferencesFromResource(R.xml.preferences_general);

            final ListPreference theme =
                    (ListPreference) findPreference(SettingsConstantsUI.KEY_PREF_THEME);
            initializeTheme(getActivity(), theme);
            final Preference reset =
                    findPreference(SettingsConstantsUI.KEY_PREF_RESET_SETTINGS);
            initializeReset(getActivity(), reset);
            break;

        case SettingsConstantsUI.ACTION_PREFS_UPDATE:
            ApkDownloader.check(getActivity(), true);
            break;
    }
}
项目:android_nextgis_mobile    文件:SettingsFragment.java   
public static void initializeTheme(
        final Activity activity,
        final ListPreference theme)
{
    if (null != theme) {
        theme.setSummary(theme.getEntry());

        theme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
        {
            @Override
            public boolean onPreferenceChange(
                    Preference preference,
                    Object newValue)
            {
                activity.startActivity(activity.getIntent());
                activity.finish();
                return true;
            }
        });
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
        /* For list preferences, look up the correct display value in */
        /* the preference's 'entries' list (since they have separate labels/values). */
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:android-dev-challenge    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:GoUbiquitous    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:Camera-warner    文件:SettingsFragment.java   
/**
 * 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) {
        if (preference.getKey().equals(getString(R.string.pref_radius_key))) {
            preference.setSummary(value + "m");
        } else {
            // For EditTextPreferences, set the summary to the value's simple string representation.
            preference.setSummary(value);
        }
    }
}
项目:ConnectU    文件:NotificationsFragment.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
    super.onViewCreated(view, savedInstanceState);
    app = (App) getContext().getApplicationContext();
    view.setBackgroundColor(Color.parseColor("#FFFFFF"));
    SwitchPreferenceCompat preference = (SwitchPreferenceCompat)findPreference("enableNotifications");
    preference.setOnPreferenceChangeListener(onSetAlarm);
    ListPreference delay = (ListPreference)findPreference("delayNotifications");
    delay.setOnPreferenceChangeListener(onDelayChange);
    CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
    display.setOnPreferenceChangeListener(onDisplayChange);
    if (app.getPublicPreferenceB(Common.GLOBAL_SETTING_ISNOTIFON)) {
        preference.setChecked(true);
        delay.setEnabled(true);
        delay.setValueIndex(getIdByTime(app.account.getNotificationTime()));
        display.setEnabled(true);
        display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
    } else {
        preference.setChecked(false);
        delay.setEnabled(false);
        display.setEnabled(false);
        display.setChecked(false);
    }
}
项目:ConnectU    文件:NotificationsFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    NotificationManager manager = new NotificationManager(getContext());
    ListPreference delay = (ListPreference)findPreference("delayNotifications");
    CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
    app.savePublicPreference(Common.GLOBAL_SETTING_ISNOTIFON, (boolean)newValue);
    if ((boolean)newValue) {
        delay.setEnabled(true);
        display.setEnabled(true);
        display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
        manager.setRecurrentService();
    } else {
        delay.setEnabled(false);
        display.setEnabled(false);
        display.setChecked(false);
        manager.deactivateRecurrentService();
    }
    return true;
}
项目:RespawnIRC-Android    文件:SettingsFragment.java   
private static void updatePrefDefaultValue(Preference pref) {
    String realPrefKey = pref.getKey();
    pref.setPersistent(false);
    if (pref instanceof CheckBoxPreference) {
        pref.setKey("tmpKeyBool");
        CheckBoxPreference checkBoxPref = (CheckBoxPreference) pref;
        checkBoxPref.setChecked(PrefsManager.getBool(realPrefKey));
    } else if (pref instanceof SwitchPreferenceCompat) {
        pref.setKey("tmpKeyBool");
        SwitchPreferenceCompat switchPref = (SwitchPreferenceCompat) pref;
        switchPref.setChecked(PrefsManager.getBool(realPrefKey));
    } else if (pref instanceof EditTextPreference) {
        pref.setKey("tmpKeyString");
        EditTextPreference editTextPref = (EditTextPreference) pref;
        editTextPref.setText(PrefsManager.getString(realPrefKey));
    } else if (pref instanceof ListPreference) {
        pref.setKey("tmpKeyString");
        ListPreference listPref = (ListPreference) pref;
        listPref.setValue(PrefsManager.getString(realPrefKey));
    }
    pref.setPersistent(true);
    pref.setKey(realPrefKey);
}
项目:ubiquitous    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:librus-client    文件:SettingsFragment.java   
@Override
public void updateAvailableFragments(List<? extends MainFragmentPresenter> presenters) {
    ListPreference list = (ListPreference) getPreferenceScreen().findPreference("defaultFragment");

    CharSequence[] labels = StreamSupport.stream(presenters)
            .map(MainFragmentPresenter::getTitle)
            .map(this::getString)
            .toArray(CharSequence[]::new);
    CharSequence[] values = StreamSupport.stream(presenters)
            .map(MainFragmentPresenter::getTitle)
            .map(String::valueOf)
            .toArray(CharSequence[]::new);

    list.setEntries(labels);
    list.setEntryValues(values);
}
项目:android_nextgis_mobile    文件:SettingsFragment.java   
@Override
protected void createPreferences(PreferenceScreen screen)
{
    switch (mAction) {
        case SettingsConstantsUI.ACTION_PREFS_GENERAL:
            addPreferencesFromResource(R.xml.preferences_general);

            final ListPreference theme =
                    (ListPreference) findPreference(SettingsConstantsUI.KEY_PREF_THEME);
            initializeTheme(getActivity(), theme);
            final Preference reset =
                    findPreference(SettingsConstantsUI.KEY_PREF_RESET_SETTINGS);
            initializeReset(getActivity(), reset);
            break;

        case SettingsConstantsUI.ACTION_PREFS_UPDATE:
            ApkDownloader.check(getActivity(), true);
            break;
    }
}
项目:android_nextgis_mobile    文件:SettingsFragment.java   
public static void initializeTheme(
        final Activity activity,
        final ListPreference theme)
{
    if (null != theme) {
        theme.setSummary(theme.getEntry());

        theme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
        {
            @Override
            public boolean onPreferenceChange(
                    Preference preference,
                    Object newValue)
            {
                activity.startActivity(activity.getIntent());
                activity.finish();
                return true;
            }
        });
    }
}
项目:octoandroid    文件:PrinterDetailsFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:Project-Sunshine    文件:SettingsFragment.java   
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
        /* For list preferences, look up the correct display value in */
        /* the preference's 'entries' list (since they have separate labels/values). */
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}