當前位置: 首頁>>代碼示例>>Java>>正文


Java ListPreference.setEntryValues方法代碼示例

本文整理匯總了Java中android.support.v7.preference.ListPreference.setEntryValues方法的典型用法代碼示例。如果您正苦於以下問題:Java ListPreference.setEntryValues方法的具體用法?Java ListPreference.setEntryValues怎麽用?Java ListPreference.setEntryValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.preference.ListPreference的用法示例。


在下文中一共展示了ListPreference.setEntryValues方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateAvailableFragments

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@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);
}
 
開發者ID:shymmq,項目名稱:librus-client,代碼行數:17,代碼來源:SettingsFragment.java

示例2: configureHomePage

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
private void configureHomePage() {
    String[] namesArray = getResources().getStringArray(R.array.query_filters_ids_names);
    String[] titlesArray = getResources().getStringArray(R.array.query_filters_ids_titles);
    String[] authArray = getResources().getStringArray(R.array.query_filters_auth);

    boolean authenticated = mAccount.hasAuthenticatedAccessMode();
    List<String> names = new ArrayList<>();
    List<String> titles = new ArrayList<>();
    int count = authArray.length;
    for (int i = 0; i < count ; i++) {
        if ((authenticated || !Boolean.valueOf(authArray[i]))
                && isEntrySupported(namesArray[i])) {
            names.add(namesArray[i]);
            titles.add(titlesArray[i]);
        }
    }

    List<CustomFilter> filters = Preferences.getAccountCustomFilters(getContext(), mAccount);
    if (filters != null) {
        for (CustomFilter filter : filters) {
            names.add(Constants.CUSTOM_FILTER_PREFIX + filter.mId);
            titles.add(filter.mName);
        }
    }

    // Add the entries y values
    mHomePage = (ListPreference) findPreference(PREF_ACCOUNT_HOME_PAGE);
    mHomePage.setEntries(titles.toArray(new String[titles.size()]));
    mHomePage.setEntryValues(names.toArray(new String[names.size()]));
    mHomePage.setDefaultValue(Preferences.getDefaultHomePageForAccount(mAccount));
    String value = Preferences.getAccountHomePage(getContext(), mAccount);
    if (!names.contains(value)) {
        value = Preferences.getDefaultHomePageForAccount(mAccount);
    }
    mHomePage.setValue(value);
    updateHomePageSummary(mHomePage.getValue());
    mHomePage.setOnPreferenceChangeListener(this);
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:39,代碼來源:AccountSettingsFragment.java

示例3: onCreatePreferences

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.preferences);

    Preference openSchdSetup = findPreference(PrefUtils.PREF_OPEN_SCHEDULE_SETUP);
    openSchdSetup.setOnPreferenceClickListener(preference -> {
        Intent intent = new Intent(getActivity(), ScheduleSetupActivity.class);
        intent.putExtra(ScheduleSetupActivity.EXTRA_OPTIONAL, true);
        startActivity(intent);
        return true;
    });

    ListPreference modes = (ListPreference) findPreference(PrefUtils.PREF_MODE);
    modes.setEntryValues(new String[]{"0", "1", "2"});
}
 
開發者ID:mvhs-apps,項目名稱:mvhs-app,代碼行數:16,代碼來源:SettingsActivity.java

示例4: onCreate

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Make sure default values are applied. In a real app, you would
    // want this in a shared function that is used to retrieve the
    // SharedPreferences wherever they are needed.
    PreferenceManager.setDefaultValues(getActivity(),
            R.xml.preference_app, false);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preference_app);

    if (BuildConfig.FOSS_ONLY) {
        // disable tracking if GA is not used
        CheckBoxPreference trackingErrors = (CheckBoxPreference) findPreference(PreferenceWrapper.PREF_TRACKING_ERRORS);
        trackingErrors.setEnabled(false);
        trackingErrors.setChecked(false);
    }

    ListPreference mapFiles = (ListPreference) findPreference(PreferenceWrapper.PREF_MAP_FILE);
    if (mapFiles != null) {
        ArrayList<String> entries = new ArrayList<>();
        ArrayList<String> entryValues = new ArrayList<>();

        CollectMapFiles(entries, entryValues);

        mapFiles.setEntries(entries.toArray(new CharSequence[entries.size()]));
        mapFiles.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));

        int index = Math
                .max(mapFiles.findIndexOfValue(getPreferenceManager().getSharedPreferences().getString(
                        mapFiles.getKey(), "")), 0);
        mapFiles.setValueIndex(index);

    }

}
 
開發者ID:marunjar,項目名稱:anewjkuapp,代碼行數:39,代碼來源:SettingsFragment.java

示例5: populateListPreference

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
private <T extends Enum> void populateListPreference(
    ListPreference pref, T[] enumValues, Map<T, String> displayValues) {
  String[] entryValues = new String[enumValues.length];
  String[] entryDisplay = new String[enumValues.length];
  for (int i = 0; i < entryValues.length; i++) {
    entryValues[i] = enumValues[i].toString();
    entryDisplay[i] = displayValues.get(enumValues[i]);
  }
  pref.setEntryValues(entryValues);
  pref.setEntries(entryDisplay);
}
 
開發者ID:codeka,項目名稱:wwmmo,代碼行數:12,代碼來源:GameSettingsFragment.java

示例6: onCreatePreferences

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    getPreferenceManager().setSharedPreferencesName(Constants.PREF_NAME);
    addPreferencesFromResource(R.xml.settings);

    mSettingsPref = (PreferenceCategory) findPreference("settings_pref");
    mSettingsView = (Preference) findPreference("settings_view");
    mSettingsForceEnglish = (SwitchPreference) findPreference("forceenglish");
    mSettingsForceEnglish.setOnPreferenceChangeListener(this);

    mSettingsSU = (PreferenceCategory) findPreference("su_settings_pref");
    mSettingsMonitor = (PreferenceCategory) findPreference("monitor_settings");
    mSettingsNotifications = (PreferenceCategory) findPreference("notifications_settings_pref");
    mSettingsSelinux = (PreferenceCategory) findPreference("selinux_settings_pref");
    mSettingsDebug = (PreferenceCategory) findPreference("anddebug_settings_pref");
    mSettingsProps = (PreferenceCategory) findPreference("props_settings_pref");

    mApplySuDelay = (ListPreference) findPreference("apply_su_delay");
    mApplyMonitorDelay = (ListPreference) findPreference("allow_delay");

    CharSequence[] entriesSuDelay = new CharSequence[6];
    CharSequence[] entryValuesSuDelay = new CharSequence[6];
    for (int i = 0; i < 6; i++) {
        entriesSuDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i + 1) * 10)));
        entryValuesSuDelay[i] = String.valueOf((i + 1) * 10000);
    }
    mApplySuDelay.setEntries(entriesSuDelay);
    mApplySuDelay.setEntryValues(entryValuesSuDelay);

    CharSequence[] entriesMonitorDelay = new CharSequence[7];
    CharSequence[] entryValuesMonitorDelay = new CharSequence[7];
    for (int i = 0; i < 7; i++) {
        if (i == 0) {
            entriesMonitorDelay[i] = getString(R.string.disable);
            entryValuesMonitorDelay[i] = String.valueOf(i);
        } else {
            entriesMonitorDelay[i] = (String.format(getString(R.string.apply_su_delay_summary), ((i) * 5)));
            entryValuesMonitorDelay[i] = String.valueOf((i) * 5000);
        }
    }
    mApplyMonitorDelay.setEntries(entriesMonitorDelay);
    mApplyMonitorDelay.setEntryValues(entryValuesMonitorDelay);

    suVersion = Tools.SuVersion(getActivity());
    isCMSU = Tools.SuVersionBool(suVersion);

    if (!isCMSU) {
        mSettingsSU.setEnabled(false);
        mSettingsMonitor.setEnabled(false);
        mSettingsNotifications.setEnabled(false);
        mSettingsSelinux.setEnabled(false);
        mSettingsDebug.setEnabled(false);
        if (!Tools.rootAccess(getActivity())) {
            mSettingsView.setSummary(getString(R.string.device_not_root));
            mSettingsProps.setEnabled(false);
        }
    } else
        mSettingsPref.removePreference(mSettingsView);
}
 
開發者ID:bhb27,項目名稱:isu,代碼行數:60,代碼來源:Settings.java

示例7: onCreatePreferences

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle bundle, String s)
{
    super.onCreatePreferences(bundle, s);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
            getContext());

    // Get our screen which is created in Skin SettingsFragment
    PreferenceScreen screen = getPreferenceScreen();

    // Get profile preference
    PreferenceCategory category = (PreferenceCategory) screen.findPreference(KEY_PROFILE);

    // If category exists, we should add mole mapper specific things. If not, that means we
    // are not consented so we have no data to set.
    if(category != null)
    {
        // Occupation Preference
        Preference checkBoxPref = new Preference(screen.getContext());
        checkBoxPref.setKey(KEY_PROFILE_PROFESSION);
        checkBoxPref.setTitle(R.string.profession);
        checkBoxPref.setSummary(R.string.profession_unknown); // Set to prevent a "jump" when first entering the screen
        category.addPreference(checkBoxPref);
    }

    // Create the app category to place out two rpefs
    PreferenceCategory appCategory = new PreferenceCategory(screen.getContext());
    appCategory.setKey(KEY_APP);
    appCategory.setTitle(R.string.settings_app);
    appCategory.setOrder(1);
    screen.addPreference(appCategory);

    // Generate values for the mole naming convention pref
    MoleNameHelper.Gender[] values = MoleNameHelper.Gender.values();
    String[] entries = new String[values.length];
    String[] entryValues = new String[values.length];
    for(int i = 0; i < values.length; i++)
    {
        MoleNameHelper.Gender gender = values[i];
        entries[i] = getString(gender.getNameResourceId());
        entryValues[i] = Integer.toString(i);
    }

    // Create ListPreference and add to "App" category
    String defaultNamingConvention = Integer.toString(MoleNameHelper.Gender.RANDOM.ordinal());
    ListPreference namingConventionPref = new ListPreference(screen.getContext());
    namingConventionPref.setTitle(R.string.settings_app_mole_name_scheme);
    namingConventionPref.setKey(KEY_APP_MOLE_NAMING);
    namingConventionPref.setDefaultValue(defaultNamingConvention);
    namingConventionPref.setEntries(entries);
    namingConventionPref.setEntryValues(entryValues);
    namingConventionPref.setDialogTitle(R.string.settings_app_mole_name_scheme);
    String currentNamingConvInt = sharedPreferences.getString(KEY_APP_MOLE_NAMING,
            defaultNamingConvention);
    int currentNamingOrdinal = Integer.parseInt(currentNamingConvInt);
    namingConventionPref.setSummary(values[currentNamingOrdinal].getNameResourceId());
    appCategory.addPreference(namingConventionPref);
}
 
開發者ID:ResearchStack,項目名稱:MoleMapperAndroid,代碼行數:60,代碼來源:MoleMapperSettingsFragment.java

示例8: onCreatePreferences

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.password_constraint_preferences);

    mMinLength = (DpcPreferenceBase) findPreference(Keys.MIN_LENGTH);
    mMinLetters = (DpcPreferenceBase) findPreference(Keys.MIN_LETTERS);
    mMinNumeric = (DpcPreferenceBase) findPreference(Keys.MIN_NUMERIC);
    mMinLower = (DpcPreferenceBase) findPreference(Keys.MIN_LOWERCASE);
    mMinUpper = (DpcPreferenceBase) findPreference(Keys.MIN_UPPERCASE);
    mMinSymbols = (DpcPreferenceBase) findPreference(Keys.MIN_SYMBOLS);
    mMinNonLetter = (DpcPreferenceBase) findPreference(Keys.MIN_NONLETTER);

    // Populate password quality settings - messy because the only API for this requires two
    // separate String[]s.
    List<CharSequence> entries = new ArrayList<>();
    List<CharSequence> values = new ArrayList<>();
    for (Map.Entry<Integer, Integer> entry : PASSWORD_QUALITIES.entrySet()) {
        values.add(Integer.toString(entry.getKey()));
        entries.add(getString(entry.getValue()));
    }
    ListPreference quality = (ListPreference) findPreference(Keys.QUALITY);
    quality.setEntries(entries.toArray(new CharSequence[0]));
    quality.setEntryValues(values.toArray(new CharSequence[0]));

    // Expiration times.
    setup(Keys.EXPIRATION_TIME, null);
    setup(Keys.HISTORY_LENGTH, getDpm().getPasswordHistoryLength(getAdmin()));

    // Minimum quality requirement.
    setup(Keys.QUALITY, PASSWORD_QUALITIES.floorKey(getDpm().getPasswordQuality(getAdmin())));

    // Minimum length requirements.
    setup(Keys.MIN_LENGTH, getDpm().getPasswordMinimumLength(getAdmin()));
    setup(Keys.MIN_LETTERS, getDpm().getPasswordMinimumLetters(getAdmin()));
    setup(Keys.MIN_NUMERIC, getDpm().getPasswordMinimumNumeric(getAdmin()));
    setup(Keys.MIN_LOWERCASE, getDpm().getPasswordMinimumLowerCase(getAdmin()));
    setup(Keys.MIN_UPPERCASE, getDpm().getPasswordMinimumUpperCase(getAdmin()));
    setup(Keys.MIN_SYMBOLS, getDpm().getPasswordMinimumSymbols(getAdmin()));
    setup(Keys.MIN_NONLETTER, getDpm().getPasswordMinimumNonLetter(getAdmin()));

    setPreferencesConstraint();
}
 
開發者ID:googlesamples,項目名稱:android-testdpc,代碼行數:43,代碼來源:PasswordConstraintsFragment.java

示例9: setDetails

import android.support.v7.preference.ListPreference; //導入方法依賴的package包/類
@Override
public void setDetails(AccountConfig config, String[] tlsMethods) {
    for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) {
        final Preference current = tlsCategory.getPreference(i);
        final ConfigKey key = ConfigKey.fromString(current.getKey());

        if (current instanceof TwoStatePreference) {
            ((TwoStatePreference) current).setChecked(config.getBool(key));
        } else {
            if (key == ConfigKey.TLS_CA_LIST_FILE) {
                File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE));
                current.setSummary(crt.getName());
                setFeedbackIcon(current);
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) {
                current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName());
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_CERTIFICATE_FILE) {
                File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE));
                current.setSummary(pem.getName());
                setFeedbackIcon(current);
                checkForRSAKey();
                current.setOnPreferenceClickListener(filePickerListener);
            } else if (key == ConfigKey.TLS_METHOD) {
                ListPreference listPref = (ListPreference) current;
                String curVal = config.get(key);
                listPref.setEntries(tlsMethods);
                listPref.setEntryValues(tlsMethods);
                listPref.setValue(curVal);
                current.setSummary(curVal);
            } else if (current instanceof EditTextPreference) {
                String val = config.get(key);
                ((EditTextPreference) current).setText(val);
                current.setSummary(val);
            } else {
                current.setSummary(config.get(key));
            }
        }

        current.setOnPreferenceChangeListener(tlsListener);
    }
}
 
開發者ID:savoirfairelinux,項目名稱:ring-client-android,代碼行數:43,代碼來源:SecurityAccountFragment.java


注:本文中的android.support.v7.preference.ListPreference.setEntryValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。