Java 类android.preference.ListPreference 实例源码

项目:android-mrz-reader    文件:PreferencesActivity.java   
/**
 * Set the default preference values.
 *
 * @param savedInstanceState the current Activity's state, as passed by
 *            Android
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);

  sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

  listPreferenceSourceLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
  listPreferenceTargetLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_TARGET_LANGUAGE_PREFERENCE);
  listPreferenceTranslator = (ListPreference) getPreferenceScreen().findPreference(KEY_TRANSLATOR);    
  listPreferenceOcrEngineMode = (ListPreference) getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
  editTextPreferenceCharacterBlacklist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
  editTextPreferenceCharacterWhitelist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
  listPreferencePageSegmentationMode = (ListPreference) getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);

  // Create the entries/entryvalues for the translation target language list.
  initTranslationTargetList();

}
项目:q-mail    文件:AccountSettings.java   
private void removeListEntry(ListPreference listPreference, String remove) {
    CharSequence[] entryValues = listPreference.getEntryValues();
    CharSequence[] entries = listPreference.getEntries();

    CharSequence[] newEntryValues = new String[entryValues.length - 1];
    CharSequence[] newEntries = new String[entryValues.length - 1];

    for (int i = 0, out = 0; i < entryValues.length; i++) {
        CharSequence value = entryValues[i];
        if (!value.equals(remove)) {
            newEntryValues[out] = value;
            newEntries[out] = entries[i];
            out++;
        }
    }

    listPreference.setEntryValues(newEntryValues);
    listPreference.setEntries(newEntries);
}
项目:q-mail    文件:AccountSettings.java   
@Override
protected void onPreExecute() {
    autoExpandFolder = (ListPreference) findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
    autoExpandFolder.setEnabled(false);
    archiveFolder = (ListPreference) findPreference(PREFERENCE_ARCHIVE_FOLDER);
    archiveFolder.setEnabled(false);
    draftsFolder = (ListPreference) findPreference(PREFERENCE_DRAFTS_FOLDER);
    draftsFolder.setEnabled(false);
    sentFolder = (ListPreference) findPreference(PREFERENCE_SENT_FOLDER);
    sentFolder.setEnabled(false);
    spamFolder = (ListPreference) findPreference(PREFERENCE_SPAM_FOLDER);
    spamFolder.setEnabled(false);
    trashFolder = (ListPreference) findPreference(PREFERENCE_TRASH_FOLDER);
    trashFolder.setEnabled(false);

    if (!isMoveCapable) {
        PreferenceScreen foldersCategory =
                (PreferenceScreen) findPreference(PREFERENCE_CATEGORY_FOLDERS);
        foldersCategory.removePreference(archiveFolder);
        foldersCategory.removePreference(spamFolder);
        foldersCategory.removePreference(draftsFolder);
        foldersCategory.removePreference(sentFolder);
        foldersCategory.removePreference(trashFolder);
    }
}
项目:Treebolic    文件:SettingsActivity.java   
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // inflate
    addPreferencesFromResource(R.xml.pref_service);

    // preference
    final ListPreference listPreference = (ListPreference) findPreference(Settings.PREF_SERVICE);

    // activity
    final SettingsActivity activity = (SettingsActivity) getActivity();

    // connect to data
    activity.fillWithServiceData(listPreference);

    // bind
    activity.bind(listPreference, Settings.getStringPref(activity, listPreference.getKey()), activity.listener);
}
项目:Cable-Android    文件:ChatsPreferenceFragment.java   
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_chats);

  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_MOBILE_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_WIFI_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_ROAMING_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());

  findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
      .setOnPreferenceClickListener(new TrimNowClickListener());
  findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
      .setOnPreferenceChangeListener(new TrimLengthValidationListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF));
}
项目:android-slideshow    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:PeSanKita-android    文件:NotificationsPreferenceFragment.java   
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  masterSecret = getArguments().getParcelable("master_secret");
  addPreferencesFromResource(R.xml.preferences_notifications);

  this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.RINGTONE_PREF)
      .setOnPreferenceChangeListener(new RingtoneSummaryListener());
  this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF)
      .setOnPreferenceChangeListener(new NotificationPrivacyListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
  initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
项目:Treebolic    文件:SettingsActivity.java   
/**
 * Connect list preference to service data
 *
 * @param listPreference list preference
 */
private void fillWithServiceData(@NonNull final ListPreference listPreference)
{
    final List<HashMap<String, Object>> services = Services.getServices(this, true);
    if (services != null)
    {
        final int n = services.size();
        final String[] entries = new String[n];
        final String[] values = new String[n];
        for (int i = 0; i < n; i++)
        {
            final HashMap<String, Object> service = services.get(i);
            entries[i] = (String) service.get(Services.LABEL);
            values[i] = (String) service.get(Services.PACKAGE) + '/' + service.get(Services.NAME);
        }
        listPreference.setEntries(entries);
        listPreference.setEntryValues(values);
    }
}
项目:BeaconMqtt    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:C500Companion    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:text_converter    文件:PreferencesUtil.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:bananapeel    文件:ServerPreferencesScreen.java   
private void setKeys(PreferenceScreen screen)
{
    for(int i = 0; i < screen.getPreferenceCount(); i++)
    {
        Preference preference = screen.getPreference(i);
        String key = server + ";" + preference.getKey();
        preference.setKey(key);
        if(preference instanceof EditIntPreference)
            ((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
        else if(preference instanceof EditTextPreference)
            ((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
        else if(preference instanceof ListPreference)
            ((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
        else if(preference instanceof CheckBoxPreference)
            ((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
        if(preference instanceof PreferenceScreen)
            setKeys((PreferenceScreen)preference);
    }
}
项目:social-journal    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:SecScanQR    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:AndroidIRCLogViewer    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:AndiCar    文件:PreferenceActivity.java   
/**
 * Sets the summary of the preference according to its value
 *
 * @param preference
 * @param value
 */
private static void setPreferenceSummaryByValue(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    }
    else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
}
项目:QuakeRepor    文件:SettingActivity.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            CharSequence[] labels  = listPreference.getEntries();
            preference.setSummary(labels[prefIndex]);
        }

    }else {
        preference.setSummary(stringValue);
    }
    return true;
}
项目:proto-collecte    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:javaide    文件:PreferencesUtil.java   
@Override
public boolean onPreferenceChange(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.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
项目:buildAPKsSamples    文件:CustomRestrictionsFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.custom_prefs);

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
项目:LaunchTime    文件:SettingsActivity.java   
protected static void setListPreferenceIconsPacksData(ListPreference lp, Context context) {
    IconsHandler iph = GlobState.getIconsHandler(context);

    iph.loadAvailableIconsPacks();

    Map<String, String> iconsPacks = iph.getAllIconsThemes();

    CharSequence[] entries = new CharSequence[iconsPacks.size()];
    CharSequence[] entryValues = new CharSequence[iconsPacks.size()];

    int i = 0;
    for (String packageIconsPack : iconsPacks.keySet()) {
        entries[i] = iconsPacks.get(packageIconsPack);
        entryValues[i] = packageIconsPack;
        i++;
    }

    lp.setEntries(entries);
    lp.setDefaultValue(IconsHandler.DEFAULT_PACK);
    lp.setEntryValues(entryValues);
}
项目:GitHub    文件:SettingsActivity.java   
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("env_dir") && !init) {
            editPref.setText(PrefStore.getEnvDir(this));
            pref.setSummary(editPref.getText());
        }

        if (editPref.getKey().equals("http_conf") &&
                editPref.getText().isEmpty()) {
            editPref.setText(PrefStore.getHttpConf(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
项目:Linphone4Android    文件:SettingsFragment.java   
private void initTunnelSettings() {
    if (!LinphoneManager.getLc().isTunnelAvailable()) {
        return;
    }

    setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_host_key, mPrefs.getTunnelHost());
    setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_port_key, String.valueOf(mPrefs.getTunnelPort()));
    ListPreference tunnelModePref = (ListPreference) findPreference(getString(R.string.pref_tunnel_mode_key));
    String tunnelMode = mPrefs.getTunnelMode();
    tunnelModePref.setSummary(tunnelMode);
    tunnelModePref.setValue(tunnelMode);
}
项目:Rey-MusicPlayer    文件:SettingsAppearanceFragment.java   
@Override
public void onCreate(Bundle onSavedInstanceState) {
    super.onCreate(onSavedInstanceState);
    addPreferencesFromResource(R.xml.settings_appearance);
    mPreferenceManager = this.getPreferenceManager();

    mStartUpScreenPreference = (ListPreference) mPreferenceManager.findPreference("preference_key_startup_screen");
    mStartUpScreenPreference.setOnPreferenceChangeListener((preference, o) -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.restart_app);
        builder.setMessage(R.string.restart_app_des);
        builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
            dialogInterface.dismiss();
            Intent intent = getActivity().getBaseContext().getPackageManager().getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName());
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            getActivity().finish();
            startActivity(intent);
        });
        builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
        builder.create().show();

        return true;
    });


}
项目:Linphone4Android    文件:SettingsFragment.java   
private void initializePreferredVideoSizePreferences(ListPreference pref) {
    List<CharSequence> entries = new ArrayList<CharSequence>();
    List<CharSequence> values = new ArrayList<CharSequence>();
    for (String name : LinphoneManager.getLc().getSupportedVideoSizes()) {
        entries.add(name);
        values.add(name);
    }

    setListPreferenceValues(pref, entries, values);

    String value = mPrefs.getPreferredVideoSize();
    pref.setSummary(value);
    pref.setValue(value);
}
项目:WeatherAlarmClock    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        preference.setSummary(stringValue);
    }
    return true;
}
项目:Linphone4Android    文件:SettingsFragment.java   
private void initLimeEncryptionPreference(ListPreference pref) {
    List<CharSequence> entries = new ArrayList<CharSequence>();
    List<CharSequence> values = new ArrayList<CharSequence>();
    entries.add(getString(R.string.lime_encryption_entry_disabled));
    values.add(LinphoneLimeState.Disabled.toString());

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc == null || !lc.isLimeEncryptionAvailable()) {
        setListPreferenceValues(pref, entries, values);
        pref.setEnabled(false);
        return;
    }

    entries.add(getString(R.string.lime_encryption_entry_mandatory));
    values.add(LinphoneLimeState.Mandatory.toString());
    entries.add(getString(R.string.lime_encryption_entry_preferred));
    values.add(LinphoneLimeState.Preferred.toString());
    setListPreferenceValues(pref, entries, values);

    LinphoneLimeState lime = mPrefs.getLimeEncryption();
    if (lime == LinphoneLimeState.Disabled) {
        pref.setSummary(getString(R.string.lime_encryption_entry_disabled));
    } else if (lime == LinphoneLimeState.Mandatory) {
        pref.setSummary(getString(R.string.lime_encryption_entry_mandatory));
    } else if (lime == LinphoneLimeState.Preferred) {
        pref.setSummary(getString(R.string.lime_encryption_entry_preferred));
    }
    pref.setValue(lime.toString());
}
项目:Linphone4Android    文件:AccountPreferencesFragment.java   
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) {
    CharSequence[] contents = new CharSequence[entries.size()];
    entries.toArray(contents);
    pref.setEntries(contents);
    contents = new CharSequence[values.size()];
    values.toArray(contents);
    pref.setEntryValues(contents);
}
项目:Cable-Android    文件:ListSummaryPreferenceFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
  ListPreference listPref   = (ListPreference) preference;
  int            entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);

  listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
                      ? listPref.getEntries()[entryIndex]
                      : getString(R.string.preferences__led_color_unknown));
  return true;
}
项目:SampleAppArch    文件:SettingsActivity.java   
@Override
public boolean onPreferenceChange(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.
    ListPreference listPreference = (ListPreference) preference;
    int index = listPreference.findIndexOfValue(stringValue);

    // Set the summary to reflect the new value.
    preference.setSummary(
        index >= 0
            ? listPreference.getEntries()[index]
            : null);

  } else if (preference instanceof RingtonePreference) {
    // For ringtone preferences, look up the correct display value
    // using RingtoneManager.
    if (TextUtils.isEmpty(stringValue)) {
      // Empty values correspond to 'silent' (no ringtone).
      preference.setSummary(R.string.pref_ringtone_silent);

    } else {
      Ringtone ringtone = RingtoneManager.getRingtone(
          preference.getContext(), Uri.parse(stringValue));

      if (ringtone == null) {
        // Clear the summary if there was a lookup error.
        preference.setSummary(null);
      } else {
        // Set the summary to reflect the new ringtone display
        // name.
        String name = ringtone.getTitle(preference.getContext());
        preference.setSummary(name);
      }
    }

  } else {
    // For all other preferences, set the summary to the value's
    // simple string representation.
    preference.setSummary(stringValue);
  }
  return true;
}
项目:AC2RD    文件:Preferences.java   
private void onSharedPreferenceAudioFormatChanged()
{
    try
    {
        Preference preferencesAudioFormat = findPreference("preferences_audio_format");
        if (preferencesAudioFormat instanceof ListPreference)
        {
            ListPreference listPreferencesAudioFormat = (ListPreference) preferencesAudioFormat;
            preferencesAudioFormatValue = (String) listPreferencesAudioFormat.getEntry();
            preferencesAudioFormat.setSummary(getString(R.string.preferences_audio_format_summary) + " " + listPreferencesAudioFormat.getEntry());

            Log.d("Preferences", "onSharedPreferenceAudioFormatChanged : " + getApplicationContext().getString(R.string.log_preferences_audio_format_changed) + " : " + listPreferencesAudioFormat.getEntry());

            if(isInit == true)
            {
                databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_audio_format_changed) + " : " + listPreferencesAudioFormat.getEntry(), new Date().getTime(), 3, false);
            }
        }
    }
    catch (Exception e)
    {
        Log.w("Preferences", "onSharedPreferenceAudioFormatChanged : " + getApplicationContext().getString(R.string.log_preferences_error_audio_format_changed) + " : " + e);

        if(isInit == true)
        {
            databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_error_audio_format_changed), new Date().getTime(), 2, false);
        }
    }
}
项目:ultrasonic    文件:SettingsFragment.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME);
    videoPlayer = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER);
    maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI);
    maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE);
    cacheSize = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE);
    cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION);
    preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT);
    bufferLength = (ListPreference) findPreference(Constants.PREFERENCES_KEY_BUFFER_LENGTH);
    incrementTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_INCREMENT_TIME);
    networkTimeout = (ListPreference) findPreference(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT);
    maxAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ALBUMS);
    maxSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_SONGS);
    maxArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ARTISTS);
    defaultArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ARTISTS);
    defaultSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SONGS);
    defaultAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ALBUMS);
    chatRefreshInterval = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CHAT_REFRESH_INTERVAL);
    directoryCacheTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DIRECTORY_CACHE_TIME);
    mediaButtonsEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_MEDIA_BUTTONS);
    lockScreenEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SHOW_LOCK_SCREEN_CONTROLS);
    sendBluetoothAlbumArt = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART);
    sendBluetoothNotifications = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS);
    viewRefresh = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIEW_REFRESH);
    imageLoaderConcurrency = (ListPreference) findPreference(Constants.PREFERENCES_KEY_IMAGE_LOADER_CONCURRENCY);
    sharingDefaultDescription = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_DESCRIPTION);
    sharingDefaultGreeting = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_GREETING);
    sharingDefaultExpiration = (TimeSpanPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION);
    serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVERS_KEY);

    sharingDefaultGreeting.setText(Util.getShareGreeting(getActivity()));
    setupClearSearchPreference();
    setupGaplessControlSettingsV14();
}
项目:keepass2android    文件:LatinIMESettings.java   
@Override
protected void onCreate(Bundle icicle) {
    SharedPreferences prefs =
            PreferenceManager.getDefaultSharedPreferences(this);
    Design.updateTheme(this, prefs);

    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs);
    mQuickFixes = (CheckBoxPreference) findPreference(QUICK_FIXES_KEY);
    mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
    prefs.registerOnSharedPreferenceChangeListener(this);


}
项目:AC2RD    文件:Preferences.java   
private void onSharedPreferenceAudioSourceChanged()
{
    try
    {
        Preference preferencesAudioSource = findPreference("preferences_audio_source");
        if (preferencesAudioSource instanceof ListPreference)
        {
            ListPreference listPreferencesAudioSource = (ListPreference) preferencesAudioSource;
            preferencesAudioSourceValue = (String) listPreferencesAudioSource.getEntry();
            preferencesAudioSource.setSummary(getString(R.string.preferences_audio_source_summary) + " " + listPreferencesAudioSource.getEntry());

            Log.d("Preferences", "onSharedPreferenceAudioSourceChanged : " + getApplicationContext().getString(R.string.log_preferences_audio_source_changed) + " : " + listPreferencesAudioSource.getEntry());

            if(isInit == true)
            {   
                databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_audio_source_changed) + " : " + listPreferencesAudioSource.getEntry(), new Date().getTime(), 3, false);
            }
        }
    }
    catch (Exception e)
    {
        Log.w("Preferences", "onSharedPreferenceAudioSourceChanged : " + getApplicationContext().getString(R.string.log_preferences_error_audio_source_changed) + " : " + e);

        if(isInit == true)
        {
            databaseManager.insertLog(getApplicationContext(), "" + getApplicationContext().getString(R.string.log_preferences_error_audio_source_changed), new Date().getTime(), 2, false);
        }
    }
}
项目:order-by-android    文件:SettingsActivity.java   
private void updatePreference(Preference preference) {
    //Mostra corretamente os objetos
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        listPreference.setSummary(listPreference.getEntry());
    }
    else if(preference instanceof EditTextPreference)
    {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    }
}
项目:Botanist    文件:SettingsActivity.java   
/**
 * Update a preference
 * @param key - which preference
 */
private void updatePref(String key){
    ListPreference preference = (ListPreference) findPreference(key);
    CharSequence entry = preference.getEntry();
    String value = preference.getValue();
    preference.setSummary(entry);
    SharedPreferences.Editor editor = mPreferences.edit();
    // Fucking strangely, a string cannot be parsed to an integer
    editor.putString(key, value);
    editor.apply();
}
项目:PeSanKita-android    文件:ListSummaryPreferenceFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
  ListPreference listPref   = (ListPreference) preference;
  int            entryIndex = Arrays.asList(listPref.getEntryValues()).indexOf(value);

  listPref.setSummary(entryIndex >= 0 && entryIndex < listPref.getEntries().length
                      ? listPref.getEntries()[entryIndex]
                      : getString(R.string.preferences__led_color_unknown));
  return true;
}
项目:PeSanKita-android    文件:AppearancePreferenceFragment.java   
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_appearance);

  this.findPreference(TextSecurePreferences.THEME_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.LANGUAGE_PREF).setOnPreferenceChangeListener(new ListSummaryListener());
  initializeListSummary((ListPreference)findPreference(TextSecurePreferences.THEME_PREF));
  initializeListSummary((ListPreference)findPreference(TextSecurePreferences.LANGUAGE_PREF));
}
项目:decoy    文件:AVChatSettingsFragment.java   
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();

    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        preference.setSummary(stringValue);
    }
    return true;
}
项目:CSipSimple    文件:GenericPrefs.java   
/**
 * Set summary of a list field If empty will display default summary If one
 * item selected will display item name
 * 
 * @param fieldName the preference key name
 */
public void setListFieldSummary(String fieldName) {
    PreferenceScreen pfs = getPreferenceScreen();
    ListPreference pref = (ListPreference) pfs.findPreference(fieldName);
    if (pref == null) {
        Log.w(THIS_FILE, "Unable to find preference " + fieldName);
        return;
    }

    CharSequence val = pref.getEntry();
    if (TextUtils.isEmpty(val)) {
        val = getDefaultFieldSummary(fieldName);
    }
    setPreferenceSummary(pref, val);
}