本文整理汇总了Java中android.support.v7.preference.ListPreference.findIndexOfValue方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.findIndexOfValue方法的具体用法?Java ListPreference.findIndexOfValue怎么用?Java ListPreference.findIndexOfValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.ListPreference
的用法示例。
在下文中一共展示了ListPreference.findIndexOfValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list (since they have separate labels/values).
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(stringValue);
if (prefIndex >= 0) {
preference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else {
// For other preferences, set the summary to the value's simple string representation.
preference.setSummary(stringValue);
}
}
示例2: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
/**
* Updates the summary for the preference
*
* @param preference The preference to be updated
* @param value The value that the preference was updated to
*/
private void setPreferenceSummary(Preference preference, String value) {
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
if (preference.getKey().equals(getString(R.string.pref_radius_key))) {
preference.setSummary(value + "m");
} else {
// For EditTextPreferences, set the summary to the value's simple string representation.
preference.setSummary(value);
}
}
}
示例3: onPreferenceChange
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String stringValue = newValue.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list (since they have separate labels/values).
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(stringValue);
if (prefIndex >= 0) {
preference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else {
// For other preferences, set the summary to the value's simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例4: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, Object value) {
String stringValue = value.toString();
String key = preference.getKey();
if (preference instanceof ListPreference) {
/* For list preferences, look up the correct display value in */
/* the preference's 'entries' list (since they have separate labels/values). */
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(stringValue);
if (prefIndex >= 0) {
preference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else {
// For other preferences, set the summary to the value's simple string representation.
preference.setSummary(stringValue);
}
}
示例5: onPreferenceChange
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? (listPreference.getEntries()[index])
.toString().replaceAll("%", "%%")
: null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例6: onPreferenceChange
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
if (value.toString().equals(""))
return false;
preference.setSummary(stringValue);
}
return true;
}
示例7: onSharedPreferenceChanged
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference preference = findPreference(key);
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(sharedPreferences.getString(key, ""));
if (prefIndex >= 0) {
if (getString(R.string.listen_clipboard_time_key).equals(key)) {
preference.setSummary(getString(R.string.listen_clipboard_des,
listPreference.getEntries()[prefIndex]));
}
}
} else if (preference instanceof CheckBoxPreference) {
boolean result = sharedPreferences.getBoolean(key, false);
findPreference(getString(R.string.listen_clipboard_time_key)).setEnabled(result);
}
}
示例8: onPreferenceChange
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例9: updateListPreference
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private static void updateListPreference(
Resources resources,
ListPreference preference,
int arrayValuesId) {
final int valueIndex = preference.findIndexOfValue(preference.getValue());
final String summary = resources.getStringArray(arrayValuesId)[valueIndex];
preference.setSummary(summary);
}
示例10: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, String value) {
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(value);
if (index >= 0) {
listPreference.setSummary(listPreference.getEntries()[index]);
}
}
}
示例11: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void setPreferenceSummary(android.support.v7.preference.Preference preference, String value) {
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
// For EditTextPreferences, set the summary to the value's simple string representation.
preference.setSummary(value);
}
}
示例12: setSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private static void setSummary(Preference preference, @NonNull Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else {
preference.setSummary(stringValue);
}
}
示例13: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
/**
* Updates the summary for the preference
*
* @param preference The preference to be updated
* @param value The value that the preference was updated to
*/
private void setPreferenceSummary(Preference preference, String value) {
// COMPLETED (3) Don't forget to add code here to properly set the summary for an EditTextPreference
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
preference.setSummary(value);
}
}
示例14: setPreferenceSummary
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, String value) {
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
}
}
示例15: onPreferenceChange
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
if (null != value) {
int index = listPreference.findIndexOfValue(value.toString());
CharSequence summary;
if (index >= 0) {
summary = listPreference.getEntries()[index];
} else if (null != listPreference.getValue()) {
summary = listPreference.getValue();
} else {
summary = null;
}
// Set the summary to reflect the new value.
preference.setSummary(summary);
}
} else if (preference instanceof TimePreferenceCompat) {
if (null != value && value instanceof String) {
LocalTime time = LocalTime.parse((String) value, DatabaseHelper.DB_TIME_FORMATTER);
//TimePreferenceCompat timePreference = (TimePreferenceCompat) preference;
preference.setSummary(DateTimeHelper.convertLocalTimeToString(preference.getContext(),
time.getHourOfDay(), time.getMinuteOfHour()));
}
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
if (value instanceof String) {
preference.setSummary(value.toString());
}
}
return true;
}