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


Java ListPreference.setEntryValues方法代码示例

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


在下文中一共展示了ListPreference.setEntryValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setListPreferenceIconsPacksData

import android.preference.ListPreference; //导入方法依赖的package包/类
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);
}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:22,代码来源:SettingsActivity.java

示例2: setIconPacksList

import android.preference.ListPreference; //导入方法依赖的package包/类
public void setIconPacksList(Map<String, String> iconPacks) {
	ListPreference preference = (ListPreference)findPreference(Keys.ICON_PACK);
	CharSequence[] e = new CharSequence[iconPacks.size()+1];
	CharSequence[] v = new CharSequence[iconPacks.size()+1];
	e[0] = getResources().getString(R.string.defaultIconPack);
	v[0] = "default";
	Set<Map.Entry<String, String>> entryset = iconPacks.entrySet();
	short i=1;
	for (Map.Entry<String, String> entry: entryset) {
		e[i] = entry.getKey();
		v[i] = entry.getValue();
		i++;
	}
	preference.setEntries(e);
	preference.setEntryValues(v);
}
 
开发者ID:HenriDellal,项目名称:emerald,代码行数:17,代码来源:Options.java

示例3: setRpcServerPreferenceData

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setRpcServerPreferenceData(ListPreference lp) {
    NetworkInfo[] networks = ethereumNetworkRepository.getAvailableNetworkList();
    CharSequence[] entries = new CharSequence[networks.length];
    for (int ii = 0; ii < networks.length; ii++) {
        entries[ii] = networks[ii].name;
    }

    CharSequence[] entryValues = new CharSequence[networks.length];
    for (int ii = 0; ii < networks.length; ii++) {
        entryValues[ii] = networks[ii].name;
    }

    String currentValue = ethereumNetworkRepository.getDefaultNetwork().name;

    lp.setEntries(entries);
    lp.setDefaultValue(currentValue);
    lp.setValue(currentValue);
    lp.setSummary(currentValue);
    lp.setEntryValues(entryValues);
}
 
开发者ID:TrustWallet,项目名称:trust-wallet-android,代码行数:21,代码来源:SettingsFragment.java

示例4: fillWithServiceData

import android.preference.ListPreference; //导入方法依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:24,代码来源:SettingsActivity.java

示例5: removeListEntry

import android.preference.ListPreference; //导入方法依赖的package包/类
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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:AccountSettings.java

示例6: setListPreferenceValues

import android.preference.ListPreference; //导入方法依赖的package包/类
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);
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:9,代码来源:SettingsFragment.java

示例7: fillLayout

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void fillLayout(final SipProfile account) {
	super.fillLayout(account);
	
	CharSequence[] states = new CharSequence[] {"act", "nsw", "nt", "qld", "sa", "tas", "vic", "wa"};
	
       accountState = new ListPreference(parent);
       accountState.setEntries(states);
       accountState.setEntryValues(states);
       accountState.setKey("state");
       accountState.setDialogTitle(R.string.w_iinet_state);
       accountState.setTitle(R.string.w_iinet_state);
       accountState.setSummary(R.string.w_iinet_state_desc);
       accountState.setDefaultValue("act");
       addPreference(accountState);
       
       String domain = account.reg_uri;
       if( domain != null ) {
        for(CharSequence state : states) {
        	String currentComp = "sip:sip."+state+".iinet.net.au";
        	if( currentComp.equalsIgnoreCase(domain) ) {
        		accountState.setValue(state.toString());
        		break;
        	}
        }
       }
       
       accountUsername.setTitle(R.string.w_iinet_username);
	accountUsername.setDialogTitle(R.string.w_iinet_username);
	accountPassword.setTitle(R.string.w_iinet_password);
	accountPassword.setDialogTitle(R.string.w_iinet_password);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:33,代码来源:IiNet.java

示例8: updateLocationPreferenceForXGeo

import android.preference.ListPreference; //导入方法依赖的package包/类
/**
 * Updates the location preference to indicate that the site has access to location (via X-Geo)
 * for searches that happen from the omnibox.
 * @param preference The Location preference to modify.
 */
private void updateLocationPreferenceForXGeo(Preference preference) {
    ListPreference listPreference = (ListPreference) preference;
    Resources res = getResources();
    listPreference.setEntries(new String[] {
            res.getString(R.string.website_settings_permissions_allow_dse),
            res.getString(ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)),
    });
    listPreference.setEntryValues(new String[] {
            ContentSetting.DEFAULT.toString(),
            ContentSetting.BLOCK.toString(),
    });
    listPreference.setValueIndex(0);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:SingleWebsitePreferences.java

示例9: inflateCountrySelection

import android.preference.ListPreference; //导入方法依赖的package包/类
private void inflateCountrySelection() {
    ListPreference countrySelectionPreference = (ListPreference) findPreference(PreferencesUtils.PREFERENCES_SELECTED_COUNTRY);
    countrySelectionPreference.setEntries(LocaleUtils.getAvailableLocales());
    countrySelectionPreference.setEntryValues(LocaleUtils.getAvailableIso3Codes());
    countrySelectionPreference.setDefaultValue(LocaleUtils.getDeviceLocale(countrySelectionPreference.getContext()));
    countrySelectionPreference.setValueIndex(countrySelectionPreference.findIndexOfValue(Prefs.with(countrySelectionPreference.getContext()).read(countrySelectionPreference.getKey(), LocaleUtils.getDeviceLocale(countrySelectionPreference.getContext()))));
    bindPreferenceSummaryToValue(countrySelectionPreference);
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:9,代码来源:SettingsActivity.java

示例10: setAccount

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setAccount(final ListPreference listPreference)
        {
            listPreference.setPersistent(true);
            ArrayList<CharSequence> accnames = ((PreferencesActivity) getActivity()).mAccountNames;

            CharSequence[] names = new CharSequence[accnames.size()];
            names = accnames.toArray(names);

            listPreference.setEntries(names);
            listPreference.setEntryValues(names);

//            String currentSelected = mSharedPrefs.getString("account_selected", "None");
//            int index = listPreference.findIndexOfValue(currentSelected);
//            listPreference.setValueIndex(index != -1 ? index : 0);

            listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
            {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue)
                {
//                    mSharedPrefs.edit().putString("account_selected", newValue.toString()).apply();
                    int index = listPreference.findIndexOfValue(newValue.toString());
                    listPreference.setValueIndex(index != -1 ? index : 0);
                    return false;
                }
            });
        }
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:28,代码来源:PreferencesActivity.java

示例11: onViewCreated

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final PreferenceScreen preferenceScreen = this.getPreferenceScreen();

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            ProjectService projectService = new ProjectService();
            ArrayList<Project> projects = projectService.getAllProjects();

            //Project temp = new Project();
            //projects.add(temp.setProjectId(5L).setProjectName("foo").setBuildingName("FFUF"));


            PreferenceCategory projectPref = (PreferenceCategory) preferenceScreen.findPreference("pref_key_proj_info");
            ListPreference projectIdList = new ListPreference(preferenceScreen.getContext());
            projectIdList.setKey("project_id_list");
            projectIdList.setTitle("Project");
            projectIdList.setSummary("Select the localization project.");

            // Get project ids and names from projects list.
            String projectNames[] = new String[projects.size()];
            String projectIds[] = new String[projects.size()];
            Log.i(TAG, "Projects:");
            for (int i = 0; i < projects.size(); i++) {
                Log.i(TAG, projects.get(i).getProjectId() + " => " + projects.get(i).getProjectName());
                projectIds[i] = "" + projects.get(i).getProjectId();
                projectNames[i] = projects.get(i).getProjectId() + ": " + projects.get(i).getProjectName() + " (Building: " + projects.get(i).getBuildingName() + ")";
            }

            // Set drop down entries and initialize preferences.
            projectIdList.setEntries(projectNames);
            projectIdList.setEntryValues(projectIds);
            projectIdList.setOnPreferenceChangeListener(new ProjectPreferenceChangeListener(preferenceScreen));
            projectPref.addPreference(projectIdList);
        }
    });
    t.start();
}
 
开发者ID:ProjectIndoor,项目名称:projectindoorapp,代码行数:41,代码来源:SettingsActivity.java

示例12: initStartPagePreference

import android.preference.ListPreference; //导入方法依赖的package包/类
private void initStartPagePreference(ListPreference lp) {
    ISettings.IDrawerSettings drawerSettings = Settings.get()
            .drawerSettings();

    ArrayList<String> enabledCategoriesName = new ArrayList<>();
    ArrayList<String> enabledCategoriesValues = new ArrayList<>();

    enabledCategoriesName.add(getString(R.string.last_closed_page));
    enabledCategoriesValues.add("last_closed");

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.FRIENDS)) {
        enabledCategoriesName.add(getString(R.string.friends));
        enabledCategoriesValues.add("1");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.DIALOGS)) {
        enabledCategoriesName.add(getString(R.string.dialogs));
        enabledCategoriesValues.add("2");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.FEED)) {
        enabledCategoriesName.add(getString(R.string.feed));
        enabledCategoriesValues.add("3");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.FEEDBACK)) {
        enabledCategoriesName.add(getString(R.string.drawer_feedback));
        enabledCategoriesValues.add("4");
    }

    if(drawerSettings.isCategoryEnabled(SwitchableCategory.NEWSFEED_COMMENTS)){
        enabledCategoriesName.add(getString(R.string.drawer_newsfeed_comments));
        enabledCategoriesValues.add("12");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.GROUPS)) {
        enabledCategoriesName.add(getString(R.string.groups));
        enabledCategoriesValues.add("5");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.PHOTOS)) {
        enabledCategoriesName.add(getString(R.string.photos));
        enabledCategoriesValues.add("6");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.VIDEOS)) {
        enabledCategoriesName.add(getString(R.string.videos));
        enabledCategoriesValues.add("7");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.MUSIC)) {
        enabledCategoriesName.add(getString(R.string.music));
        enabledCategoriesValues.add("8");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.DOCS)) {
        enabledCategoriesName.add(getString(R.string.attachment_documents));
        enabledCategoriesValues.add("9");
    }

    if (drawerSettings.isCategoryEnabled(SwitchableCategory.BOOKMARKS)) {
        enabledCategoriesName.add(getString(R.string.bookmarks));
        enabledCategoriesValues.add("10");
    }

    lp.setEntries(enabledCategoriesName.toArray(new CharSequence[enabledCategoriesName.size()]));
    lp.setEntryValues(enabledCategoriesValues.toArray(new CharSequence[enabledCategoriesValues.size()]));
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:69,代码来源:PreferencesFragment.java

示例13: onCreate

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_advanced);

    final Resources res = getResources();
    final Context context = getActivity();

    // When we are called from the Settings application but we are not already running, some
    // singleton and utility classes may not have been initialized.  We have to call
    // initialization method of these classes here. See {@link LatinIME#onCreate()}.
    AudioAndHapticFeedbackManager.init(context);

    final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();

    if (!Settings.isInternal(prefs)) {
        removePreference(Settings.SCREEN_DEBUG);
    }

    if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) {
        removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
    }

    // TODO: consolidate key preview dismiss delay with the key preview animation parameters.
    if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
        removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
    } else {
        // TODO: Cleanup this setup.
        final ListPreference keyPreviewPopupDismissDelay =
                (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
        final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
                R.integer.config_key_preview_linger_timeout));
        keyPreviewPopupDismissDelay.setEntries(new String[] {
                res.getString(R.string.key_preview_popup_dismiss_no_delay),
                res.getString(R.string.key_preview_popup_dismiss_default_delay),
        });
        keyPreviewPopupDismissDelay.setEntryValues(new String[] {
                "0",
                popupDismissDelayDefaultValue
        });
        if (null == keyPreviewPopupDismissDelay.getValue()) {
            keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
        }
        keyPreviewPopupDismissDelay.setEnabled(
                Settings.readKeyPreviewPopupEnabled(prefs, res));
    }

    setupKeypressVibrationDurationSettings();
    setupKeypressSoundVolumeSettings();
    setupKeyLongpressTimeoutSettings();
    setupKeyboardHeightSettings();
    refreshEnablingsOfKeypressSoundAndVibrationSettings();
    setupKeyboardColorSettings();
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:55,代码来源:AdvancedSettingsFragment.java

示例14: setUpListPreference

import android.preference.ListPreference; //导入方法依赖的package包/类
/**
 * Initialize a ListPreference with a certain value.
 * @param preference The ListPreference to initialize.
 * @param value The value to initialize it to.
 */
private void setUpListPreference(Preference preference, ContentSetting value) {
    if (value == null) {
        getPreferenceScreen().removePreference(preference);
        return;
    }

    ListPreference listPreference = (ListPreference) preference;

    int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
    CharSequence[] keys = new String[2];
    CharSequence[] descriptions = new String[2];
    keys[0] = ContentSetting.ALLOW.toString();
    keys[1] = ContentSetting.BLOCK.toString();
    descriptions[0] = getResources().getString(
            ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW));
    descriptions[1] = getResources().getString(
            ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK));
    listPreference.setEntryValues(keys);
    listPreference.setEntries(descriptions);
    int index = (value == ContentSetting.ALLOW ? 0 : 1);
    listPreference.setValueIndex(index);
    int explanationResourceId = ContentSettingsResources.getExplanation(contentType);
    if (explanationResourceId != 0) {
        listPreference.setTitle(explanationResourceId);
    }

    if (listPreference.isEnabled()) {
        SiteSettingsCategory category =
                SiteSettingsCategory.fromContentSettingsType(contentType);
        if (category != null && !category.enabledInAndroid(getActivity())) {
            listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity()));
            listPreference.setEnabled(false);
        } else {
            listPreference.setIcon(ContentSettingsResources.getIcon(contentType));
        }
    } else {
        listPreference.setIcon(
                ContentSettingsResources.getDisabledIcon(contentType, getResources()));
    }

    preference.setSummary("%s");
    listPreference.setOnPreferenceChangeListener(this);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:49,代码来源:SingleWebsitePreferences.java

示例15: onCreate

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_advanced);

    final Resources res = getResources();
    final Context context = getActivity();

    // When we are called from the Settings application but we are not already running, some
    // singleton and utility classes may not have been initialized.  We have to call
    // initialization method of these classes here. See {@link LatinIME#onCreate()}.
    AudioAndHapticFeedbackManager.init(context);

    final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();

    if (!Settings.isInternal(prefs)) {
        removePreference(Settings.SCREEN_DEBUG);
    }

    if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) {
        removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
    }

    // TODO: consolidate key preview dismiss delay with the key preview animation parameters.
    if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
        removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
    } else {
        // TODO: Cleanup this setup.
        final ListPreference keyPreviewPopupDismissDelay =
                (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
        final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
                R.integer.config_key_preview_linger_timeout));
        keyPreviewPopupDismissDelay.setEntries(new String[] {
                res.getString(R.string.key_preview_popup_dismiss_no_delay),
                res.getString(R.string.key_preview_popup_dismiss_default_delay),
        });
        keyPreviewPopupDismissDelay.setEntryValues(new String[] {
                "0",
                popupDismissDelayDefaultValue
        });
        if (null == keyPreviewPopupDismissDelay.getValue()) {
            keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
        }
        keyPreviewPopupDismissDelay.setEnabled(
                Settings.readKeyPreviewPopupEnabled(prefs, res));
    }

    setupKeypressVibrationDurationSettings();
    setupKeypressSoundVolumeSettings();
    setupKeyLongpressTimeoutSettings();
    refreshEnablingsOfKeypressSoundAndVibrationSettings();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:53,代码来源:AdvancedSettingsFragment.java


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