Java Code Examples for androidx.preference.TwoStatePreference#setOnPreferenceChangeListener()
The following examples show how to use
androidx.preference.TwoStatePreference#setOnPreferenceChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TalkBackSelectorPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { context = getActivity().getApplicationContext(); prefs = SharedPreferencesUtils.getSharedPreferences(context); PreferenceSettingsUtils.addPreferencesFromResource(this, R.xml.selector_preferences); final TwoStatePreference selectorActivation = (TwoStatePreference) findPreference(getString(R.string.pref_selector_activation_key)); if (selectorActivation != null) { selectorActivation.setOnPreferenceChangeListener(selectorActivationChangeListener); enableOrDisableSelectorSettings(selectorActivation.isChecked()); } }
Example 2
Source File: TalkBackDeveloperPreferencesActivity.java From talkback with Apache License 2.0 | 5 votes |
/** Assigns the appropriate intent to the touch exploration preference. */ private void initTouchExplorationPreference() { final TwoStatePreference prefTouchExploration = (TwoStatePreference) findPreference(getString(R.string.pref_explore_by_touch_reflect_key)); if (prefTouchExploration == null) { return; } // Ensure that changes to the reflected preference's checked state never // trigger content observers. prefTouchExploration.setPersistent(false); // Synchronize the reflected state. updateTouchExplorationDisplay(); // Set up listeners that will keep the state synchronized. prefTouchExploration.setOnPreferenceChangeListener(touchExplorationChangeListener); // Initialize preference dialog exploreByTouchDialog = new AlertDialog.Builder(this.getActivity()) .setTitle(R.string.dialog_title_disable_exploration) .setMessage(R.string.dialog_message_disable_exploration) .setNegativeButton(android.R.string.cancel, null) .setOnCancelListener(null) .setPositiveButton( android.R.string.ok, (DialogInterface dialog, int which) -> { if (setTouchExplorationRequested(false)) { prefTouchExploration.setChecked(false); } }) .create(); }