当前位置: 首页>>代码示例>>Java>>正文


Java ListPreference.setEntries方法代码示例

本文整理汇总了Java中android.support.v7.preference.ListPreference.setEntries方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.setEntries方法的具体用法?Java ListPreference.setEntries怎么用?Java ListPreference.setEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.ListPreference的用法示例。


在下文中一共展示了ListPreference.setEntries方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: configureFetchItems

import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void configureFetchItems() {
    ListPreference fetchedItems = (ListPreference) findPreference(PREF_ACCOUNT_FETCHED_ITEMS);
    CharSequence[] values = fetchedItems.getEntryValues();
    int count = values.length;
    CharSequence[] labels = new CharSequence[count];
    for (int i = 0; i < count; i++) {
        labels[i] = getString(R.string.account_settings_fetched_items_format, values[i]);
    }
    fetchedItems.setEntries(labels);
}
 
开发者ID:jruesga,项目名称:rview,代码行数:11,代码来源:AccountSettingsFragment.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: initializeLocationAccuracy

import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeLocationAccuracy(
        final ListPreference listPreference,
        final boolean isTracks)
{
    if (listPreference != null) {
        Context ctx = listPreference.getContext();
        CharSequence[] entries = new CharSequence[3];
        entries[0] = ctx.getString(R.string.pref_location_accuracy_gps);
        entries[1] = ctx.getString(R.string.pref_location_accuracy_cell);
        entries[2] = ctx.getString(R.string.pref_location_accuracy_gps) +
                " & " +
                ctx.getString(R.string.pref_location_accuracy_cell);
        listPreference.setEntries(entries);
        listPreference.setSummary(listPreference.getEntry());

        listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
        {
            @Override
            public boolean onPreferenceChange(
                    Preference preference,
                    Object newValue)
            {
                int value = Integer.parseInt(newValue.toString());
                CharSequence summary = ((ListPreference) preference).getEntries()[value - 1];
                preference.setSummary(summary);

                sectionWork(preference.getContext(), isTracks);

                return true;
            }
        });
    }
}
 
开发者ID:nextgis,项目名称:android_gisapp,代码行数:34,代码来源:SettingsFragment.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: SetupPreferences

import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public void SetupPreferences() {

        ListPreference pUM = (ListPreference) findPreference("prefUM");
        ListPreference pUMSpeed = (ListPreference) findPreference("prefUMSpeed");
        ListPreference pGPSDistance = (ListPreference) findPreference("prefGPSdistance");
        ListPreference pGPSUpdateFrequency = (ListPreference) findPreference("prefGPSupdatefrequency");
        ListPreference pKMLAltitudeMode = (ListPreference) findPreference("prefKMLAltitudeMode");
        ListPreference pShowTrackStatsType = (ListPreference) findPreference("prefShowTrackStatsType");
        ListPreference pShowDirections = (ListPreference) findPreference("prefShowDirections");
        EditTextPreference pAltitudeCorrection = (EditTextPreference) findPreference("prefAltitudeCorrectionRaw");

        altcorm = Double.valueOf(prefs.getString("prefAltitudeCorrection", "0"));
        altcor = prefs.getString("prefUM", "0").equals("0") ? altcorm : altcorm * M_TO_FT;

        if (prefs.getString("prefUM", "0").equals("0")) {       // Metric
            pUMSpeed.setEntries(R.array.UMSpeed_Metric);
            pGPSDistance.setEntries(R.array.GPSDistance_Metric);
            pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " m" : getString(R.string.pref_AltitudeCorrection_summary_not_defined));

        }
        if (prefs.getString("prefUM", "0").equals("8")) {       // Imperial
            pUMSpeed.setEntries(R.array.UMSpeed_Imperial);
            pGPSDistance.setEntries(R.array.GPSDistance_Imperial);
            pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " ft" : getString(R.string.pref_AltitudeCorrection_summary_not_defined));
        }
        if (prefs.getString("prefUM", "0").equals("16")) {       // Aerial / Nautical
            pUMSpeed.setEntries(R.array.UMSpeed_AerialNautical);
            pGPSDistance.setEntries(R.array.GPSDistance_Imperial);
            pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " ft" : getString(R.string.pref_AltitudeCorrection_summary_not_defined));
        }

        Log.w("myApp", "[#] FragmentSettings.java - prefAltitudeCorrectionRaw = " + prefs.getString("prefAltitudeCorrectionRaw", "0")) ;
        Log.w("myApp", "[#] FragmentSettings.java - prefAltitudeCorrection = " + prefs.getString("prefAltitudeCorrection", "0")) ;

        // Set all summaries
        pUMSpeed.setSummary(pUMSpeed.getEntry());
        pUM.setSummary(pUM.getEntry());
        pGPSDistance.setSummary(pGPSDistance.getEntry());
        pGPSUpdateFrequency.setSummary(pGPSUpdateFrequency.getEntry());
        pKMLAltitudeMode.setSummary(pKMLAltitudeMode.getEntry());
        pShowTrackStatsType.setSummary(pShowTrackStatsType.getEntry());
        pShowDirections.setSummary(pShowDirections.getEntry());
    }
 
开发者ID:BasicAirData,项目名称:GPSLogger,代码行数:44,代码来源:FragmentSettings.java


注:本文中的android.support.v7.preference.ListPreference.setEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。