本文整理汇总了Java中android.preference.MultiSelectListPreference.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java MultiSelectListPreference.getEntries方法的具体用法?Java MultiSelectListPreference.getEntries怎么用?Java MultiSelectListPreference.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.MultiSelectListPreference
的用法示例。
在下文中一共展示了MultiSelectListPreference.getEntries方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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());
}
示例3: onPreferenceChange
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference instanceof MultiSelectListPreference) {
MultiSelectListPreference multiListPreference =
(MultiSelectListPreference) preference;
int accountCount = multiListPreference.getEntries().length;
int selectedCount = ((Set<String>) value).size();
preference.setSummary(preference.getContext().getString(
R.string.pref_summary_accounts, selectedCount, accountCount));
} else {
preference.setSummary(value.toString());
}
return true;
}
示例4: onPreferenceChange
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof MultiSelectListPreference) {
// For multi select list preferences we should show a list of the selected options
MultiSelectListPreference listPreference = (MultiSelectListPreference) preference;
CharSequence[] values = listPreference.getEntries();
StringBuilder options = new StringBuilder();
for(String stream : (HashSet<String>) value) {
int index = listPreference.findIndexOfValue(stream);
if (index >= 0) {
if (options.length() != 0) {
options.append(", ");
}
options.append(values[index]);
}
}
preference.setSummary(options);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例5: setListPreferenceData
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
public static void setListPreferenceData(ListPreference lp, MultiSelectListPreference langsp, Set<String> values) {
List<String> entries = new ArrayList<>();
CharSequence[] entryValues = values.toArray(new CharSequence[entries.size()]);
CharSequence[] allEntries = langsp.getEntries();
for (String v : values) {
entries.add((String) allEntries[langsp.findIndexOfValue(v)]);
}
lp.setEntries(entries.toArray(new CharSequence[entries.size()]));
lp.setEntryValues(entryValues);
lp.setDefaultValue(entryValues[0]);
bindPreferenceSummaryToValue(lp);
}
示例6: updatePrefSummary
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void updatePrefSummary(Preference p)
{
if (p instanceof ListPreference)
{
ListPreference listPref = (ListPreference) p;
p.setSummary(listPref.getEntry());
}
if (p instanceof EditTextPreference)
{
EditTextPreference editTextPref = (EditTextPreference) p;
if (p.getTitle().toString().contains("assword"))
{
p.setSummary("******");
}
else
{
p.setSummary(editTextPref.getText());
}
}
if (p instanceof MultiSelectListPreference)
{
MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
CharSequence[] entries = editMultiListPref.getEntries();
CharSequence[] entryValues = editMultiListPref.getEntryValues();
List<String> currentEntries = new ArrayList<>();
Set<String> currentEntryValues = editMultiListPref.getValues();
for (int i = 0; i < entries.length; i++)
{
if (currentEntryValues.contains(entryValues[i].toString())) currentEntries.add(entries[i].toString());
}
p.setSummary(currentEntries.toString());
}
}
示例7: updatePrefSummary
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void updatePrefSummary(Preference p) {
if (smartAssignEnable.isChecked()) {
ignoreOutOfRangeEnable.setEnabled(true);
} else {
ignoreOutOfRangeEnable.setEnabled(false);
}
if (p instanceof ListPreference) {
ListPreference listPref = (ListPreference) p;
p.setSummary(listPref.getTitle());
}
if (p instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) p;
if (p.getTitle().toString().contains("assword"))
{
p.setSummary("******");
} else {
p.setSummary(editTextPref.getText());
}
}
if (p instanceof MultiSelectListPreference) {
MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
CharSequence[] entries = editMultiListPref.getEntries();
CharSequence[] entryValues = editMultiListPref.getEntryValues();
List<String> currentEntries = new ArrayList<>();
Set<String> currentEntryValues = editMultiListPref.getValues();
for (int i = 0; i < entries.length; i++)
if (currentEntryValues.contains(entryValues[i]))
currentEntries.add(entries[i].toString());
p.setSummary(currentEntries.toString());
}
}
示例8: updatePrefsSummary
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void updatePrefsSummary(SharedPreferences sharedPreferences, String key) {
Preference pref = findPreference(key);
if (pref == null)
return;
if (pref instanceof ListPreference) {
// List Preference
ListPreference listPref = (ListPreference) pref;
listPref.setSummary(listPref.getEntry());
} else if (pref instanceof EditTextPreference) {
// EditPreference
if (key.equals(getString(R.string.preferences_settings_key_auto_refresh_interval))) {
// Set summary to be the user-description for the selected value
Logger.i("settingsAutoRefreshInterval: " + sharedPreferences.getString(key, ""));
pref.setSummary(sharedPreferences.getString(key, ""));
} else {
EditTextPreference editTextPref = (EditTextPreference) pref;
editTextPref.setSummary(editTextPref.getText());
}
} else if (pref instanceof MultiSelectListPreference) {
// MultiSelectList Preference
MultiSelectListPreference mlistPref = (MultiSelectListPreference) pref;
String summaryMListPref = "";
String and = "";
// Retrieve values
Set<String> values = mlistPref.getValues();
for (String value : values) {
// For each value retrieve index
int index = mlistPref.findIndexOfValue(value);
// Retrieve entry from index
CharSequence mEntry = index >= 0
&& mlistPref.getEntries() != null ? mlistPref
.getEntries()[index] : null;
if (mEntry != null) {
// add summary
summaryMListPref = summaryMListPref + and + mEntry;
and = ";";
}
}
// set summary
mlistPref.setSummary(summaryMListPref);
} else if (pref instanceof RingtonePreference) {
// RingtonePreference
RingtonePreference rtPref = (RingtonePreference) pref;
String uri;
if (rtPref != null) {
uri = sharedPreferences.getString(rtPref.getKey(), null);
if (uri != null) {
Ringtone ringtone = RingtoneManager.getRingtone(
this, Uri.parse(uri));
pref.setSummary(ringtone.getTitle(this));
}
}
}
// else if (pref instanceof NumberPickerPreference) {
// // My NumberPicker Preference
// NumberPickerPreference nPickerPref = (NumberPickerPreference) pref;
// nPickerPref.setSummary(nPickerPref.getValue());
// }
}
示例9: updatePrefSummary
import android.preference.MultiSelectListPreference; //导入方法依赖的package包/类
private void updatePrefSummary(Preference p) {
if (estimateWaterEnable.isChecked()) {
estimateWaterFormula.setEnabled(true);
} else {
estimateWaterFormula.setEnabled(false);
}
if (estimateLBWEnable.isChecked()) {
estimateLBWFormula.setEnabled(true);
} else {
estimateLBWFormula.setEnabled(false);
}
if (estimateFatEnable.isChecked()) {
estimateFatFormula.setEnabled(true);
} else {
estimateFatFormula.setEnabled(false);
}
if (fatEnable.isChecked()) {
fatPercentageEnable.setEnabled(true);
} else {
fatPercentageEnable.setEnabled(false);
}
if (waterEnable.isChecked()) {
waterPercentageEnable.setEnabled(true);
} else {
waterPercentageEnable.setEnabled(false);
}
if (muscleEnable.isChecked()) {
musclePercentageEnable.setEnabled(true);
} else {
musclePercentageEnable.setEnabled(false);
}
estimateWaterFormula.setSummary(EstimatedWaterMetric.getEstimatedMetric(EstimatedWaterMetric.FORMULA.valueOf(estimateWaterFormula.getValue())).getName());
estimateLBWFormula.setSummary(EstimatedLBWMetric.getEstimatedMetric(EstimatedLBWMetric.FORMULA.valueOf(estimateLBWFormula.getValue())).getName());
estimateFatFormula.setSummary(EstimatedFatMetric.getEstimatedMetric(EstimatedFatMetric.FORMULA.valueOf(estimateFatFormula.getValue())).getName());
if (p instanceof EditTextPreference) {
EditTextPreference editTextPref = (EditTextPreference) p;
if (p.getTitle().toString().contains("assword"))
{
p.setSummary("******");
} else {
p.setSummary(editTextPref.getText());
}
}
if (p instanceof MultiSelectListPreference) {
MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
CharSequence[] entries = editMultiListPref.getEntries();
CharSequence[] entryValues = editMultiListPref.getEntryValues();
List<String> currentEntries = new ArrayList<>();
Set<String> currentEntryValues = editMultiListPref.getValues();
for (int i = 0; i < entries.length; i++)
if (currentEntryValues.contains(entryValues[i]))
currentEntries.add(entries[i].toString());
p.setSummary(currentEntries.toString());
}
}