當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。