本文整理汇总了Java中android.support.v7.preference.ListPreference.setOnPreferenceChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListPreference.setOnPreferenceChangeListener方法的具体用法?Java ListPreference.setOnPreferenceChangeListener怎么用?Java ListPreference.setOnPreferenceChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.ListPreference
的用法示例。
在下文中一共展示了ListPreference.setOnPreferenceChangeListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeTheme
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeTheme(
final Activity activity,
final ListPreference theme)
{
if (null != theme) {
theme.setSummary(theme.getEntry());
theme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
activity.startActivity(activity.getIntent());
activity.finish();
return true;
}
});
}
}
示例2: onViewCreated
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
app = (App) getContext().getApplicationContext();
view.setBackgroundColor(Color.parseColor("#FFFFFF"));
SwitchPreferenceCompat preference = (SwitchPreferenceCompat)findPreference("enableNotifications");
preference.setOnPreferenceChangeListener(onSetAlarm);
ListPreference delay = (ListPreference)findPreference("delayNotifications");
delay.setOnPreferenceChangeListener(onDelayChange);
CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
display.setOnPreferenceChangeListener(onDisplayChange);
if (app.getPublicPreferenceB(Common.GLOBAL_SETTING_ISNOTIFON)) {
preference.setChecked(true);
delay.setEnabled(true);
delay.setValueIndex(getIdByTime(app.account.getNotificationTime()));
display.setEnabled(true);
display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
} else {
preference.setChecked(false);
delay.setEnabled(false);
display.setEnabled(false);
display.setChecked(false);
}
}
示例3: initializeShowStatusPanel
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeShowStatusPanel(final ListPreference listPreference)
{
listPreference.setSummary(listPreference.getEntry());
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
preference.setSummary(listPreference.getEntries()[listPreference.findIndexOfValue(
(String) newValue)]);
return true;
}
});
}
示例4: initializeShowCurrentLocation
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeShowCurrentLocation(
final ListPreference listPreference)
{
listPreference.setSummary(listPreference.getEntry());
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
preference.setSummary(listPreference.getEntries()[listPreference.findIndexOfValue(
(String) newValue)]);
return true;
}
});
}
示例5: initializeMapBG
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeMapBG(final ListPreference mapBG)
{
mapBG.setSummary(mapBG.getEntry());
mapBG.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
preference.setSummary(
mapBG.getEntries()[mapBG.findIndexOfValue((String) newValue)]);
return true;
}
});
}
示例6: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
mShowFabPolicyPreference = (ListPreference) findPreference(PREF_SHOW_FAB_POLICY);
mAnimateFabEntryPreference = (CheckBoxPreference) findPreference(PREF_ANIMATE_FAB_ENTRY);
mAnimateFabColorPreference = (CheckBoxPreference) findPreference(PREF_ANIMATE_FAB_COLOR);
mShowFabAlwaysValue = getResources().getString(R.string.show_fab_policy_default_value);
mShowFabPolicyPreference.setOnPreferenceChangeListener(
new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean dependentPrefEnabled = isShowFabAlways(newValue);
if (!dependentPrefEnabled) {
// These preferences do not apply for the new PREF_SHOW_FAB_POLICY value.
// Save the preferences' checked states before we clear them, in case
// the user sets the correct value again in this Fragment instance.
mInitialAnimateFabEntryValue = mAnimateFabEntryPreference.isChecked();
mInitialAnimateFabColorValue = mAnimateFabColorPreference.isChecked();
mAnimateFabEntryPreference.setChecked(false);
mAnimateFabColorPreference.setChecked(false);
} else {
mAnimateFabEntryPreference.setChecked(mInitialAnimateFabEntryValue);
mAnimateFabColorPreference.setChecked(mInitialAnimateFabColorValue);
}
setPreferencesDependentOnShowFabPolicyEnabled(dependentPrefEnabled);
return true; // Write to storage
}
});
// Initialize the enabled states of the dependent Preferences.
setPreferencesDependentOnShowFabPolicyEnabled(isShowFabAlways(
mShowFabPolicyPreference.getValue()));
}
示例7: initThemePref
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void initThemePref(String theme) {
ListPreference themePref = (ListPreference)
findPreference(getString(R.string.pref_key_theme));
String theme_name = Settings.Utils.getThemeName(getActivity(), theme);
themePref.setSummary(theme_name);
themePref.setOnPreferenceChangeListener(this);
}
示例8: configureHomePage
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
private void configureHomePage() {
String[] namesArray = getResources().getStringArray(R.array.query_filters_ids_names);
String[] titlesArray = getResources().getStringArray(R.array.query_filters_ids_titles);
String[] authArray = getResources().getStringArray(R.array.query_filters_auth);
boolean authenticated = mAccount.hasAuthenticatedAccessMode();
List<String> names = new ArrayList<>();
List<String> titles = new ArrayList<>();
int count = authArray.length;
for (int i = 0; i < count ; i++) {
if ((authenticated || !Boolean.valueOf(authArray[i]))
&& isEntrySupported(namesArray[i])) {
names.add(namesArray[i]);
titles.add(titlesArray[i]);
}
}
List<CustomFilter> filters = Preferences.getAccountCustomFilters(getContext(), mAccount);
if (filters != null) {
for (CustomFilter filter : filters) {
names.add(Constants.CUSTOM_FILTER_PREFIX + filter.mId);
titles.add(filter.mName);
}
}
// Add the entries y values
mHomePage = (ListPreference) findPreference(PREF_ACCOUNT_HOME_PAGE);
mHomePage.setEntries(titles.toArray(new String[titles.size()]));
mHomePage.setEntryValues(names.toArray(new String[names.size()]));
mHomePage.setDefaultValue(Preferences.getDefaultHomePageForAccount(mAccount));
String value = Preferences.getAccountHomePage(getContext(), mAccount);
if (!names.contains(value)) {
value = Preferences.getDefaultHomePageForAccount(mAccount);
}
mHomePage.setValue(value);
updateHomePageSummary(mHomePage.getValue());
mHomePage.setOnPreferenceChangeListener(this);
}
示例9: onCreatePreferences
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.settings_general);
// initial day and night mode
ListPreference dayNightPref = (ListPreference) findPreference(DAY_NIGHT);
Observable.just(PrefsUtil.getPrefDayNightMode(getActivity()))
.map(Constant.dayNightSummary::get)
.subscribe(dayNightPref::setSummary);
dayNightPref.setOnPreferenceChangeListener(listener);
// initial image size
ListPreference imageSizePref = (ListPreference) findPreference(IMAGE_SIZE);
imageSizePref.setSummary(PrefsUtil.getPrefImageSize(getActivity()));
Observable.just(PrefsUtil.getPrefImageSize(getActivity()))
.map(Constant.imageSizeSummary::get)
.subscribe(imageSizePref::setSummary);
imageSizePref.setOnPreferenceChangeListener(listener);
// initial nickname and summary
EditTextPreference namePref = (EditTextPreference) findPreference(NICKNAME);
namePref.setSummary(PrefsUtil.getPrefNickname(getActivity()));
namePref.setOnPreferenceChangeListener(listener);
// initial signature and summary
EditTextPreference signPref = (EditTextPreference) findPreference(SIGNATURE);
signPref.setSummary(PrefsUtil.getPrefSignature(getActivity()));
signPref.setOnPreferenceChangeListener(listener);
}
示例10: initializeLocationAccuracy
import android.support.v7.preference.ListPreference; //导入方法依赖的package包/类
public static void initializeLocationAccuracy(
final ListPreference listPreference,
final boolean isTracks)
{
if (listPreference != null) {
Context ctx = listPreference.getContext();
CharSequence[] entries = new CharSequence[3];
entries[0] = ctx.getString(R.string.pref_location_accuracy_gps);
entries[1] = ctx.getString(R.string.pref_location_accuracy_cell);
entries[2] = ctx.getString(R.string.pref_location_accuracy_gps) +
" & " +
ctx.getString(R.string.pref_location_accuracy_cell);
listPreference.setEntries(entries);
listPreference.setSummary(listPreference.getEntry());
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
int value = Integer.parseInt(newValue.toString());
CharSequence summary = ((ListPreference) preference).getEntries()[value - 1];
preference.setSummary(summary);
sectionWork(preference.getContext(), isTracks);
return true;
}
});
}
}