当前位置: 首页>>代码示例>>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;未经允许,请勿转载。