當前位置: 首頁>>代碼示例>>Java>>正文


Java OnPreferenceChangeListener類代碼示例

本文整理匯總了Java中android.preference.Preference.OnPreferenceChangeListener的典型用法代碼示例。如果您正苦於以下問題:Java OnPreferenceChangeListener類的具體用法?Java OnPreferenceChangeListener怎麽用?Java OnPreferenceChangeListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnPreferenceChangeListener類屬於android.preference.Preference包,在下文中一共展示了OnPreferenceChangeListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.document_mode_preferences);
    getActivity().setTitle(R.string.tabs_and_apps_title);

    mDocumentModeManager = DocumentModeManager.getInstance(getActivity());

    mDocumentModeSwitch = (SwitchPreference) findPreference(PREF_DOCUMENT_MODE_SWITCH);

    boolean isdocumentModeEnabled = !mDocumentModeManager.isOptedOutOfDocumentMode();
    mDocumentModeSwitch.setChecked(isdocumentModeEnabled);

    mDocumentModeSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if ((boolean) newValue == !mDocumentModeManager.isOptedOutOfDocumentMode()) {
                return true;
            }
            createOptOutAlertDialog((boolean) newValue).show();
            return true;
        }
    });
}
 
開發者ID:Smalinuxer,項目名稱:Vafrinn,代碼行數:25,代碼來源:DocumentModePreference.java

示例2: initVibrateWhenRinging

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
private void initVibrateWhenRinging(PreferenceCategory root) {
    mVibrateWhenRinging = (TwoStatePreference) root.findPreference(KEY_VIBRATE_WHEN_RINGING);
    if (mVibrateWhenRinging == null) {
        Log.i(TAG, "Preference not found: " + KEY_VIBRATE_WHEN_RINGING);
        return;
    }
    if (!mVoiceCapable || !Utils.isUserOwner()) {
        root.removePreference(mVibrateWhenRinging);
        mVibrateWhenRinging = null;
        return;
    }
    mVibrateWhenRinging.setPersistent(false);
    updateVibrateWhenRinging();
    mVibrateWhenRinging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final boolean val = (Boolean) newValue;
            return Settings.System.putInt(getContentResolver(),
                    Settings.System.VIBRATE_WHEN_RINGING,
                    val ? 1 : 0);
        }
    });
}
 
開發者ID:ric96,項目名稱:lineagex86,代碼行數:24,代碼來源:SoundSettings.java

示例3: onActivityCreated

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:22,代碼來源:HomepagePreferences.java

示例4: onCreate

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:21,代碼來源:DoNotTrackPreference.java

示例5: initPhysicalWebSwitch

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
private void initPhysicalWebSwitch() {
    ChromeSwitchPreference physicalWebSwitch =
            (ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);

    physicalWebSwitch.setChecked(
            PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());

    physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enabled = (boolean) newValue;
            if (enabled) {
                PhysicalWebUma.onPrefsFeatureEnabled(getActivity());
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled(getActivity());
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:23,代碼來源:PhysicalWebPreferenceFragment.java

示例6: onCreate

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.autofill_preferences);
    getActivity().setTitle(R.string.prefs_autofill);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    setPreferenceCategoryIcons();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:19,代碼來源:AutofillPreferences.java

示例7: onCreate

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    registerReceiver(mLoggedOutReceiver, new IntentFilter(Foursquared.INTENT_ACTION_LOGGED_OUT));

    addPreferencesFromResource(R.xml.preferences);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    
    Preference advanceSettingsPreference = getPreferenceScreen().findPreference(
            Preferences.PREFERENCE_ADVANCED_SETTINGS);
    advanceSettingsPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            ((Foursquared) getApplication()).requestUpdateUser();
            return false;
        }
    });
}
 
開發者ID:Kamshak,項目名稱:foursquared,代碼行數:19,代碼來源:PreferenceActivity.java

示例8: initPreferences

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
private void initPreferences() {
    addPreferencesFromResource(R.xml.prefs);

    hardwareKeyboardNotice = findPreference(getString(R.string.hardware_keyboard_notice_key));
    imeNotSetNotice = findPreference(getString(R.string.ime_not_set_notice_key));
    displayImePreference = (CheckBoxPreference) findPreference(getString(R.string.display_ime_key));
    displayAnimationPreference = (CheckBoxPreference) findPreference(getString(R.string.display_animation_key));

    displayImePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Boolean shouldDisplayIme = (Boolean) newValue;

            if (!shouldDisplayIme) {
                displayAnimationPreference.setChecked(false);
            }

            return true;
        }
    });

    refreshPreferences();
}
 
開發者ID:MusalaSoft,項目名稱:atmosphere-ime,代碼行數:25,代碼來源:AtmosphereIMESettings.java

示例9: configUnitsListPreference

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
/**
 * Configures the preferred units list preference.
 */
private void configUnitsListPreference() {
  @SuppressWarnings("deprecation")
  ListPreference listPreference = (ListPreference) findPreference(
      getString(R.string.stats_units_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {

      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue);
      configRateListPreference(metricUnits);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
  String[] values = getResources().getStringArray(R.array.stats_units_values);
  String[] options = getResources().getStringArray(R.array.stats_units_options);
  configureListPreference(listPreference, options, options, values, value, listener);
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:23,代碼來源:StatsSettingsActivity.java

示例10: configSensorType

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void configSensorType(boolean hasAntSupport) {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.sensor_type_key));
  String value = PreferencesUtils.getString(
      this, R.string.sensor_type_key, PreferencesUtils.SENSOR_TYPE_DEFAULT);
  String[] options = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_options : R.array.sensor_type_bluetooth_options);
  String[] values = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_values : R.array.sensor_type_bluetooth_values);

  if (!hasAntSupport && value.equals(R.string.sensor_type_value_ant)) {
    value = PreferencesUtils.SENSOR_TYPE_DEFAULT;
    PreferencesUtils.setString(this, R.string.sensor_type_key, value);
  }

  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiBySensorType((String) newValue);
      return true;
    }
  };
  configureListPreference(preference, options, options, values, value, listener);
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:26,代碼來源:SensorSettingsActivity.java

示例11: configTrackColorModePerference

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
/**
 * Configures the track color mode preference.
 */
@SuppressWarnings("deprecation")
private void configTrackColorModePerference() {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.track_color_mode_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiByTrackColorMode((String) newValue);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT);
  String[] values = getResources().getStringArray(R.array.track_color_mode_values);
  String[] options = getResources().getStringArray(R.array.track_color_mode_options);
  String[] summary = getResources().getStringArray(R.array.track_color_mode_summary);
  configureListPreference(preference, summary, options, values, value, listener);
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:22,代碼來源:MapSettingsActivity.java

示例12: configureListPreference

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
/**
 * Configures a list preference.
 * 
 * @param listPreference the list preference
 * @param summary the summary array
 * @param options the options array
 * @param values the values array
 * @param value the value
 * @param listener optional listener
 */
protected void configureListPreference(ListPreference listPreference, final String[] summary,
    final String[] options, final String[] values, String value,
    final OnPreferenceChangeListener listener) {
  listPreference.setEntryValues(values);
  listPreference.setEntries(options);
  listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updatePreferenceSummary(pref, summary, values, (String) newValue);
      if (listener != null) {
        listener.onPreferenceChange(pref, newValue);
      }
      return true;
    }
  });
  updatePreferenceSummary(listPreference, summary, values, value);
  if (listener != null) {
    listener.onPreferenceChange(listPreference, value);
  }
}
 
開發者ID:Plonk42,項目名稱:mytracks,代碼行數:31,代碼來源:AbstractSettingsActivity.java

示例13: initGpsLogIntervalControl

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
/**
 * Initializes gps logging interval.
 */
private void initGpsLogIntervalControl() {
	// Update GPS logging interval summary to the current value
	final Preference pref = findPreference(org.openbmap.Preferences.KEY_GPS_LOGGING_INTERVAL);
	pref.setSummary(
               PreferenceManager.getDefaultSharedPreferences(this).getString(org.openbmap.Preferences.KEY_GPS_LOGGING_INTERVAL, org.openbmap.Preferences.VAL_GPS_LOGGING_INTERVAL)
                       + " " + getResources().getString(R.string.prefs_gps_logging_interval_seconds)
                       + ". " + getResources().getString(R.string.prefs_gps_logging_interval_summary));
	pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
           @Override
           public boolean onPreferenceChange(final Preference preference, final Object newValue) {
               // Set summary with the interval and "seconds"
               preference.setSummary(newValue
                       + " " + getResources().getString(R.string.prefs_gps_logging_interval_seconds)
                       + ". " + getResources().getString(R.string.prefs_gps_logging_interval_summary));
               return true;
           }
       });
}
 
開發者ID:saintbyte,項目名稱:openbmap,代碼行數:22,代碼來源:SettingsActivity.java

示例14: onCreate

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	addPreferencesFromResource(R.xml.preferences);
	
	sPref = this.getSharedPreferences(Globals.SHARED_PREF, Context.MODE_PRIVATE);
	
	p = (EditTextPreference) findPreference(Globals.NICKNAME_DATA);
	nicklistener = new OnPreferenceChangeListener() {
		
		@Override
		public boolean onPreferenceChange(Preference preference, Object newValue) {
			SharedPreferences.Editor editor = sPref.edit();
			editor.putString(Globals.NICKNAME_DATA, (String) newValue);
			Log.d(Globals.TAG, ""+newValue.toString());
			editor.commit();
			return true;
		}
	};
}
 
開發者ID:dks-rub,項目名稱:meshchat,代碼行數:22,代碼來源:SettingsActivity.java

示例15: createOverrideBackButtonChangeListener

import android.preference.Preference.OnPreferenceChangeListener; //導入依賴的package包/類
/**
 * Creates a listener, which allows to adapt the behavior of the {@link PreferenceActivity} when
 * the value, which determines, whether the action bar's back button should be overwritten, has
 * been changed.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnPreferenceChangeListener}
 */
private OnPreferenceChangeListener createOverrideBackButtonChangeListener() {
    return new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            if (newValue != null) {
                boolean overrideNavigationIcon = (boolean) newValue;
                ((PreferenceActivity) getActivity()).overrideNavigationIcon(overrideNavigationIcon);
            }

            return true;
        }

    };
}
 
開發者ID:michael-rapp,項目名稱:AndroidPreferenceActivity,代碼行數:24,代碼來源:BehaviorPreferenceFragment.java


注:本文中的android.preference.Preference.OnPreferenceChangeListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。