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


Java ListPreference.setDefaultValue方法代碼示例

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


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

示例1: initializeTransportPreference

import android.preference.ListPreference; //導入方法依賴的package包/類
private void initializeTransportPreference(ListPreference pref) {
	List<CharSequence> entries = new ArrayList<CharSequence>();
	List<CharSequence> values = new ArrayList<CharSequence>();
	entries.add(getString(R.string.pref_transport_udp));
	values.add(getString(R.string.pref_transport_udp_key));
	entries.add(getString(R.string.pref_transport_tcp));
	values.add(getString(R.string.pref_transport_tcp_key));

	if (!getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
		entries.add(getString(R.string.pref_transport_tls));
		values.add(getString(R.string.pref_transport_tls_key));
	}
	setListPreferenceValues(pref, entries, values);

	if (! isNewAccount) {
		pref.setSummary(mPrefs.getAccountTransportString(n));
		pref.setDefaultValue(mPrefs.getAccountTransportKey(n));
		pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n)));
	} else {

		pref.setSummary(getString(R.string.pref_transport_udp));
		pref.setDefaultValue(getString(R.string.pref_transport_udp));
		pref.setValueIndex(entries.indexOf(getString(R.string.pref_transport_udp)));
	}
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:26,代碼來源:AccountPreferencesFragment.java

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

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

示例5: updateDateFormatList

import android.preference.ListPreference; //導入方法依賴的package包/類
private void updateDateFormatList() {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Resources res = getResources();

    ListPreference dateFormatPref = (ListPreference) findPreference("dateFormat");
    String[] dateFormatsValues = res.getStringArray(R.array.dateFormatsValues);
    String[] dateFormatsEntries = new String[dateFormatsValues.length];

    EditTextPreference customDateFormatPref = (EditTextPreference) findPreference("dateFormatCustom");
    customDateFormatPref.setDefaultValue(dateFormatsValues[0]);

    SimpleDateFormat sdformat = new SimpleDateFormat();
    for (int i=0; i<dateFormatsValues.length; i++) {
        String value = dateFormatsValues[i];
        if ("custom".equals(value)) {
            String renderedCustom;
            try {
                sdformat.applyPattern(sp.getString("dateFormatCustom", dateFormatsValues[0]));
                renderedCustom = sdformat.format(SAMPLE_DATE);
            } catch (IllegalArgumentException e) {
                renderedCustom = res.getString(R.string.error_dateFormat);
            }
            dateFormatsEntries[i] = String.format("%s:\n%s",
                    res.getString(R.string.setting_dateFormatCustom),
                    renderedCustom);
        } else {
            sdformat.applyPattern(value);
            dateFormatsEntries[i] = sdformat.format(SAMPLE_DATE);
        }
    }

    dateFormatPref.setDefaultValue(dateFormatsValues[0]);
    dateFormatPref.setEntries(dateFormatsEntries);

    setListPreferenceSummary("dateFormat");
}
 
開發者ID:hichemcesar24,項目名稱:Weather-Android,代碼行數:37,代碼來源:SettingsActivity.java

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


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