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


Java MultiSelectListPreference类代码示例

本文整理汇总了Java中android.preference.MultiSelectListPreference的典型用法代码示例。如果您正苦于以下问题:Java MultiSelectListPreference类的具体用法?Java MultiSelectListPreference怎么用?Java MultiSelectListPreference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: bindPreferenceSummaryToValue

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
/**
 * Binds a preference's summary to its value. More specifically, when the
 * preference's value is changed, its summary (line of text below the
 * preference title) is updated to reflect the value. The summary is also
 * immediately updated upon calling this method. The exact display format is
 * dependent on the type of preference.
 *
 * @see #sBindPreferenceSummaryToValueListener
 */
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference's
    // current value.
    SharedPreferences prefs = preference.getSharedPreferences();
    Object value;
    if (preference instanceof MultiSelectListPreference) {
        value = prefs.getStringSet(preference.getKey(), new HashSet<String>());
    } else {
        value = prefs.getString(preference.getKey(), "");
    }
    sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value);
}
 
开发者ID:etsy,项目名称:divertsy-client,代码行数:25,代码来源:SettingsActivity.java

示例2: onCreate

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.custom_prefs);

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:CustomRestrictionsFragment.java

示例3: setupWeekDaysPref

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
private void setupWeekDaysPref() {
    mPrefWeekDays = (MultiSelectListPreference) findPreference(PREF_KEY_QH_WEEKDAYS);
    String[] days = new DateFormatSymbols(Locale.getDefault()).getWeekdays();
    CharSequence[] entries = new CharSequence[7];
    CharSequence[] entryValues = new CharSequence[7];
    for (int i = 1; i <= 7; i++) {
        entries[i - 1] = days[i];
        entryValues[i - 1] = String.valueOf(i);
    }
    mPrefWeekDays.setEntries(entries);
    mPrefWeekDays.setEntryValues(entryValues);
    if (mPrefs.getStringSet(PREF_KEY_QH_WEEKDAYS, null) == null) {
        Set<String> value = new HashSet<String>(Arrays.asList("2", "3", "4", "5", "6"));
        mPrefs.edit().putStringSet(PREF_KEY_QH_WEEKDAYS, value).commit();
        mPrefWeekDays.setValues(value);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:QuietHoursActivity.java

示例4: updateRestaurantList

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
private void updateRestaurantList(){
    MultiSelectListPreference restaurantPrefList = (MultiSelectListPreference) findPreference(getString(R.string.pref_restaurant_list));
    List<Integer> restaurantSelectedIdList = new ArrayList<>();
    if(restaurantPrefList.getValues().isEmpty()){
        restaurantPrefList.setSummary("");
        return;
    }
    for(String s : restaurantPrefList.getValues()){
        restaurantSelectedIdList.add(restaurantPrefList.findIndexOfValue(s));
    }

    Collections.sort(restaurantSelectedIdList);

    String restaurantSummary = "";
    String separator = ", ";
    for(int i : restaurantSelectedIdList){
        restaurantSummary = restaurantSummary + restaurantPrefList.getEntries()[i] + separator;
    }

    restaurantSummary = restaurantSummary.substring(0, restaurantSummary.length() - separator.length());
    restaurantPrefList.setSummary(restaurantSummary);
}
 
开发者ID:ufrgs,项目名称:ufrgs-mobile-android,代码行数:23,代码来源:MainPreferencesFragment.java

示例5: showSetSelections

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
protected void showSetSelections (MultiSelectListPreference set, Set<String> values) {
  StringBuilder label = new StringBuilder();

  if (values.size() > 0) {
    CharSequence[] labels = set.getEntries();

    for (String value : values) {
      if (value.length() > 0) {
        if (label.length() > 0) {
          label.append('\n');
        }

        label.append(labels[set.findIndexOfValue(value)]);
      }
    }
  } else {
    label.append("none selected");
  }

  set.setSummary(label.toString());
}
 
开发者ID:google,项目名称:brailleback,代码行数:22,代码来源:SettingsActivity.java

示例6: setListPreferenceData

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
protected static void setListPreferenceData(final ListPreference lp, final MultiSelectListPreference langsp, Promise p) {
    p.done(new DoneCallback() {
        @Override
        public void onDone(Object result) {
            Map<String, Language> langs = (Map<String, Language>) result;

            List<String> entries = new ArrayList<>();
            for (Language l : langs.values()) {
                if (l.getNativeName().equals(l.getName())) {
                    entries.add(l.getNativeName());
                } else {
                    entries.add(l.getNativeName() + " (" + l.getName() + ")");
                }
            }

            langsp.setEntries(entries.toArray(new CharSequence[entries.size()]));
            langsp.setEntryValues(langs.keySet().toArray(new CharSequence[entries.size()]));
            langsp.setDefaultValue("en");
            bindPreferenceSummaryToValue(langsp);

            setListPreferenceData(lp, langsp, langsp.getValues());
        }
    });
}
 
开发者ID:feberhard,项目名称:LLAMA,代码行数:25,代码来源:SettingsActivity.java

示例7: onCreate

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_scanning);
    bindPreferenceToSummary();
    setOnPreferenceClickListeners();

    beaconFormatList = new HashSet<>();
    sharedPreferences = getPreferenceManager().getSharedPreferences();

    MultiSelectListPreference list = (MultiSelectListPreference) getPreferenceManager().findPreference("key_beacon_formats");

    Set<String> beaconFormats = sharedPreferences.getStringSet("key_beacon_formats", beaconFormatList);
    CharSequence[] sequences = beaconFormats.toArray(new CharSequence[beaconFormats.size()]);

    list.setEntries(sequences);
    list.setEntryValues(sequences);
}
 
开发者ID:BoydHogerheijde,项目名称:Beacon-Scanner-Android,代码行数:19,代码来源:SettingsFragment.java

示例8: setupElmCmdSelection

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
/**
 * set up protocol selection
 */
void setupElmCmdSelection()
{
	MultiSelectListPreference pref =
		(MultiSelectListPreference) findPreference(ELM_CMD_DISABLE);
	ElmProt.CMD[] values = ElmProt.CMD.values();
	HashSet<String> selections = new HashSet<String>();
	CharSequence[] titles = new CharSequence[values.length];
	CharSequence[] keys = new CharSequence[values.length];
	int i = 0;
	for (ElmProt.CMD cmd : values)
	{
		titles[i] = cmd.toString();
		keys[i] = cmd.toString();
		if(!cmd.isEnabled()) selections.add(cmd.toString());
		i++;
	}
	// set enries and keys
	pref.setEntries(titles);
	pref.setEntryValues(keys);
	pref.setValues(selections);
}
 
开发者ID:fr3ts0n,项目名称:AndrOBD,代码行数:25,代码来源:SettingsActivity.java

示例9: loadGroup

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
private void loadGroup() {
    // Consider adding more features here, such as those in Track and TrackPreferenceFragment
    name = (EditTextPreference) findPreference("name");
    name.setText(group.getName());
    name.setSummary(group.getName());

    description = (EditTextPreference) findPreference("description");
    description.setText(group.getDescription());
    description.setSummary(group.getDescription());

    mTracksPref = (MultiSelectListPreference) findPreference("tracks");
    mTracksPref.setValues(getTrackIdsForGroupAsSet(group.getId()));

    mTracksPref.setEntries(getAllTrackNamesAsCharSeq());
    mTracksPref.setEntryValues(getAllTrackIdsAsCharSeq());
    mTracksPref.setSummary(getTrackNamesForSummary());

}
 
开发者ID:lordi,项目名称:tickmate,代码行数:19,代码来源:GroupPreferenceFragment.java

示例10: setValue

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setValue(@NonNull Preference preference,
                     @NonNull ConfigBase.Option option,
                     @NonNull Object value) {
    int mode = (int) value;
    String[] values = new String[Integer.bitCount(mode)];
    for (int i = 1, j = 0; j < values.length; i <<= 1) {
        if (Operator.bitAnd(mode, i)) {
            values[j++] = Integer.toString(i);
        }
    }

    Set<String> valuesSet = new HashSet<>();
    Collections.addAll(valuesSet, values);

    MultiSelectListPreference mslp = (MultiSelectListPreference) preference;
    mslp.setValues(valuesSet);
}
 
开发者ID:AChep,项目名称:AcDisplay,代码行数:22,代码来源:PreferenceFragment.java

示例11: onPostExecute

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
protected void onPostExecute(Void result) {
    CharSequence[] appNamesList = appNames
            .toArray(new CharSequence[appNames.size()]);
    CharSequence[] packageNamesList = packageNames
            .toArray(new CharSequence[packageNames.size()]);

    enabledApps.setEntries(appNamesList);
    enabledApps.setEntryValues(packageNamesList);
    enabledApps.setEnabled(true);
    disabledApps.setEntries(appNamesList);
    disabledApps.setEntryValues(packageNamesList);
    disabledApps.setEnabled(true);

    Preference.OnPreferenceClickListener listener = new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((MultiSelectListPreference) preference).getDialog().getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);
            return false;
        }
    };

    enabledApps.setOnPreferenceClickListener(listener);
    disabledApps.setOnPreferenceClickListener(listener);
}
 
开发者ID:pylerSM,项目名称:XInternalSD,代码行数:26,代码来源:Preferences.java

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

示例13: onCreate

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    addPreferencesFromResource(R.xml.settings_preferences);

    mMultiSelectListPreference = (MultiSelectListPreference) findPreference("select_apply_on_boot");
    ArrayList<CharSequence> entries = new ArrayList<>();
    entries.add(getString(R.string.cpu_frequency));
    if (GpuUtils.isGpuFrequencyScalingSupported()) {
        entries.add(getString(R.string.gpu_frequency));
    }
    entries.add(getString(R.string.io));
    entries.add(getString(R.string.build_prop));
    entries.add(getString(R.string.vm));

    CharSequence[] charSequences = new CharSequence[entries.size()];
    for (int i = 0; i < entries.size(); i++) {
        charSequences[i] = entries.get(i);
    }
    mMultiSelectListPreference.setEntries(charSequences);
    mMultiSelectListPreference.setEntryValues(charSequences);
}
 
开发者ID:rahulkumar66,项目名称:Performance-Tweaker,代码行数:23,代码来源:SettingsFragment.java

示例14: onCreate

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.notification_settings);
    setHasOptionsMenu(true);

    final Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context
            .VIBRATOR_SERVICE);
    if (!vibrator.hasVibrator()) {
        final MultiSelectListPreference inAppSettings = (MultiSelectListPreference)
                findPreference(PREF_IN_APP_NOTIFICATION_SETTINGS);
        final MultiSelectListPreference outOfAppSettings = (MultiSelectListPreference)
                findPreference(PREF_OUT_OF_APP_NOTIFICATION_SETTINGS);

        inAppSettings.setEntries(R.array.notification_in_entries_no_vibrator);
        inAppSettings.setEntryValues(R.array.notification_in_values_no_vibrator);
        outOfAppSettings.setEntries(R.array.notification_out_entries_no_vibrator);
        outOfAppSettings.setEntryValues(R.array.notification_out_values_no_vibrator);
    }
}
 
开发者ID:tilal6991,项目名称:HoloIRC,代码行数:21,代码来源:NotificationPreferenceFragment.java

示例15: onCreate

import android.preference.MultiSelectListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            // Load the preferences from an XML resource
            addPreferencesFromResource(R.xml.preferences);
            
    		//dynamically populate this with the databases available
    		final DatabaseHelper dbHelper = new DatabaseHelper(getActivity());
    		dbHelper.gatherFiles();
    		final Set<String> mDBList = dbHelper.GetListofDB();
    		MultiSelectListPreference myMultPref = (MultiSelectListPreference) findPreference(getString(R.string.pref_dbs));
    		if (myMultPref != null) {
    			
    			CharSequence entries[] = new String[mDBList.size()];
    			CharSequence entryValues[] = new String[mDBList.size()];
    			int i = 0;
    			for (String str : mDBList) {
    				entries[i] = str;
    				entryValues[i] = str;
    				i++;
    			}
    			myMultPref.setEntries(entries);
    			myMultPref.setEntryValues(entryValues);
    		}
}
 
开发者ID:wbrenna,项目名称:GTFSOffline,代码行数:27,代码来源:PrefsActivity.java


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