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


Java MultiSelectListPreference.setTitle方法代碼示例

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


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

示例1: setUpUnitTypePrefs

import android.preference.MultiSelectListPreference; //導入方法依賴的package包/類
/**
 * Helper Class to setup the default Unit Type preference list in code
 */
private void setUpUnitTypePrefs() {
   PreferenceScreen screen = getPreferenceScreen();
   MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity());
   listPref.setOrder(0);
   listPref.setDialogTitle(R.string.unit_select_title);
   listPref.setKey(UNIT_TYPE_PREF_KEY);
   listPref.setSummary(R.string.unit_select_summary);
   listPref.setTitle(R.string.unit_select_title);
   listPref.setEntries(getUnitTypeNameArray(getResources()));

   String[] keyArray = getUnitTypeKeyArray(getResources());
   listPref.setEntryValues(keyArray);

   final Set<String> result = new HashSet<>();
   Collections.addAll(result, keyArray);

   listPref.setDefaultValue(result);

   screen.addPreference(listPref);
}
 
開發者ID:EvanRespaut,項目名稱:Equate,代碼行數:24,代碼來源:SettingsActivity.java

示例2: addAccountsPreference

import android.preference.MultiSelectListPreference; //導入方法依賴的package包/類
private void addAccountsPreference() {
    final String[] accounts = GmailExtension.getAllAccountNames(this);
    Set<String> allAccountsSet = new HashSet<String>();
    allAccountsSet.addAll(Arrays.asList(accounts));

    MultiSelectListPreference accountsPreference = new MultiSelectListPreference(this);
    accountsPreference.setKey(GmailExtension.PREF_ACCOUNTS);
    accountsPreference.setTitle(R.string.pref_gmail_accounts_title);
    accountsPreference.setEntries(accounts);
    accountsPreference.setEntryValues(accounts);
    accountsPreference.setDefaultValue(allAccountsSet);
    mFragment.getPreferenceScreen().addPreference(accountsPreference);

    Preference.OnPreferenceChangeListener accountsChangeListener
            = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
            int numSelected = 0;
            int numTotal = accounts.length;

            try {
                //noinspection unchecked
                Set<String> selectedAccounts = (Set<String>) value;
                if (selectedAccounts != null) {
                    numSelected = selectedAccounts.size();
                }
            } catch (ClassCastException ignored) {
            }

            preference.setSummary(getResources().getQuantityString(
                    R.plurals.pref_gmail_accounts_summary_template,
                    numTotal, numSelected, numTotal));
            return true;
        }
    };

    accountsPreference.setOnPreferenceChangeListener(accountsChangeListener);
    accountsChangeListener.onPreferenceChange(accountsPreference,
            PreferenceManager
                    .getDefaultSharedPreferences(this)
                    .getStringSet(accountsPreference.getKey(), allAccountsSet));
}
 
開發者ID:romannurik,項目名稱:dashclock,代碼行數:43,代碼來源:GmailSettingsActivity.java

示例3: addAccountsPreference

import android.preference.MultiSelectListPreference; //導入方法依賴的package包/類
private void addAccountsPreference() {
    final String[] accounts = GmailExtension.getAllAccountNames(this);
    Set<String> allAccountsSet = new HashSet<String>();
    allAccountsSet.addAll(Arrays.asList(accounts));

    MultiSelectListPreference accountsPreference = new MultiSelectListPreference(this);
    accountsPreference.setKey(GmailExtension.PREF_ACCOUNTS);
    accountsPreference.setTitle(R.string.pref_gmail_accounts_title);
    accountsPreference.setEntries(accounts);
    accountsPreference.setEntryValues(accounts);
    accountsPreference.setDefaultValue(allAccountsSet);
    getPreferenceScreen().addPreference(accountsPreference);

    Preference.OnPreferenceChangeListener accountsChangeListener
            = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
            int numSelected = 0;
            int numTotal = accounts.length;

            try {
                //noinspection unchecked
                Set<String> selectedAccounts = (Set<String>) value;
                if (selectedAccounts != null) {
                    numSelected = selectedAccounts.size();
                }
            } catch (ClassCastException ignored) {
            }

            preference.setSummary(getResources().getQuantityString(
                    R.plurals.pref_gmail_accounts_summary_template,
                    numTotal, numSelected, numTotal));
            return true;
        }
    };

    accountsPreference.setOnPreferenceChangeListener(accountsChangeListener);
    accountsChangeListener.onPreferenceChange(accountsPreference,
            PreferenceManager
                    .getDefaultSharedPreferences(this)
                    .getStringSet(accountsPreference.getKey(), allAccountsSet));
}
 
開發者ID:JesusM,項目名稱:DashClock,代碼行數:43,代碼來源:GmailSettingsActivity.java


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