Java Code Examples for androidx.preference.CheckBoxPreference#setSummary()

The following examples show how to use androidx.preference.CheckBoxPreference#setSummary() . 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: AdvancedPreferenceFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void initializePushMessagingToggle() {
  CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);

  if (TextSecurePreferences.isPushRegistered(getActivity())) {
    preference.setChecked(true);
    preference.setSummary(TextSecurePreferences.getLocalNumber(getActivity()));
  } else {
    preference.setChecked(false);
    preference.setSummary(R.string.preferences__free_private_messages_and_calls);
  }

  preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
 
Example 2
Source File: SettingsFragment.java    From fresco with MIT License 5 votes vote down vote up
private static boolean updateCheckBoxPreference(
    Resources resources,
    CheckBoxPreference preference,
    int checkedSummaryRes,
    int uncheckedSummaryRes) {
  final boolean checkboxState = preference.isChecked();
  if (checkboxState) {
    preference.setSummary(resources.getString(checkedSummaryRes));
  } else {
    preference.setSummary(resources.getString(uncheckedSummaryRes));
  }
  return checkboxState;
}