androidx.preference.Preference.setOnPreferenceClickListener()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.6k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中androidx.preference.Preference.setOnPreferenceClickListener()方法的一些代码示例,展示了Preference.setOnPreferenceClickListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Preference.setOnPreferenceClickListener()方法的具体详情如下:
包路径:androidx.preference.Preference
类名称:Preference
方法名:setOnPreferenceClickListener

Preference.setOnPreferenceClickListener介绍

暂无

代码示例

代码示例来源:origin: cSploit/android

mRubyDir.setOnPreferenceClickListener(directoryPickerWithDefaultPath);
mMsfDir.setOnPreferenceClickListener(directoryPickerWithDefaultPath);
mWipeMSF.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {

代码示例来源:origin: guardianproject/haven

findPreference(PreferenceManager.SMS_NUMBER).setOnPreferenceClickListener(preference -> {
  if (preferences.getSmsNumber().isEmpty()) {
    ((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).setText(getCountryCode());
findPreference(PreferenceManager.REGISTER_SIGNAL).setOnPreferenceClickListener(preference -> {
  if (preferences.getSignalUsername() == null) {
    ((EditTextPreference) findPreference(PreferenceManager.REGISTER_SIGNAL)).setText(getCountryCode());
prefCameraSensitivity.setOnPreferenceClickListener(preference -> {
  startActivity(new Intent(mActivity, CameraConfigureActivity.class));
  return true;
prefConfigMovement.setOnPreferenceClickListener(preference -> {
  startActivity(new Intent(mActivity, AccelConfigureActivity.class));
  return true;
prefConfigSound.setOnPreferenceClickListener(preference -> {
  startActivity(new Intent(mActivity, MicrophoneConfigureActivity.class));
  return true;
prefConfigTimeDelay.setOnPreferenceClickListener(preference -> {
  showTimeDelayDialog(PreferenceManager.CONFIG_TIME_DELAY);
  return true;
prefConfigVideoLength.setOnPreferenceClickListener(preference -> {
  showTimeDelayDialog(PreferenceManager.CONFIG_VIDEO_LENGTH);
  return true;
prefDisableBatteryOpt.setOnPreferenceClickListener(preference -> {

代码示例来源:origin: cSploit/android

mSavePath.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {

代码示例来源:origin: westnordost/StreetComplete

findPreference("license").setOnPreferenceClickListener( preference ->
});
findPreference("authors").setOnPreferenceClickListener(preference ->
});
findPreference("privacy").setOnPreferenceClickListener(preference ->
});
findPreference("repository").setOnPreferenceClickListener(preference ->
});
findPreference("report_error").setOnPreferenceClickListener(preference ->
});
findPreference("email_feedback").setOnPreferenceClickListener(preference ->

代码示例来源:origin: westnordost/StreetComplete

oauth.setOnPreferenceClickListener(preference ->
quests.setOnPreferenceClickListener(preference ->
questsInvalidation.setOnPreferenceClickListener(preference ->
questsRestoreHidden.setOnPreferenceClickListener(preference ->

代码示例来源:origin: cbeyls/fosdem-companion-android

private void setupAboutDialog() {
  findPreference(KEY_PREF_ABOUT).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      new AboutDialogFragment().show(getFragmentManager(), "about");
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidPreferenceActivity

@Override
public final void setOnPreferenceClickListener(
    @Nullable final OnPreferenceClickListener listener) {
  super.setOnPreferenceClickListener(createOnPreferenceClickListenerWrapper(listener));
}

代码示例来源:origin: cbeyls/fosdem-companion-android

@RequiresApi(api = Build.VERSION_CODES.O)
private void setupNotificationsChannel() {
  findPreference(KEY_PREF_NOTIFICATIONS_CHANNEL).setOnPreferenceClickListener(
      new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
          AlarmIntentService.startChannelNotificationSettingsActivity(getContext());
          return true;
        }
      });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the list dialog.
 */
private void initializeShowListDialogPreference() {
  Preference preference = findPreference(getString(R.string.show_list_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeListDialog();
      listDialog.setShowAnimation(createRectangularRevealAnimation(preference));
      listDialog.setDismissAnimation(createRectangularRevealAnimation(preference));
      listDialog.setCancelAnimation(createRectangularRevealAnimation(preference));
      listDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the custom dialog.
 */
private void initializeShowCustomDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_custom_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeCustomDialog();
      customDialog.setShowAnimation(createRectangularRevealAnimation(preference));
      customDialog.setDismissAnimation(createRectangularRevealAnimation(preference));
      customDialog.setCancelAnimation(createRectangularRevealAnimation(preference));
      customDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the single choice list dialog.
 */
private void initializeShowSingleChoiceListDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_single_choice_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeSingleChoiceListDialog();
      singleChoiceListDialog
          .setShowAnimation(createRectangularRevealAnimation(preference));
      singleChoiceListDialog
          .setDismissAnimation(createRectangularRevealAnimation(preference));
      singleChoiceListDialog
          .setCancelAnimation(createRectangularRevealAnimation(preference));
      singleChoiceListDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: proninyaroslav/libretorrent

@Override
public void onActivityCreated(Bundle savedInstanceState)
{
  super.onActivityCreated(savedInstanceState);
  if (activity == null)
    activity = (AppCompatActivity)getActivity();
  if (Utils.isTwoPane(activity)) {
    Fragment f = activity.getSupportFragmentManager()
        .findFragmentById(R.id.detail_fragment_container);
    if (f == null)
      setFragment(AppearanceSettingsFragment.newInstance(),
          getString(R.string.pref_header_appearance));
  }
  Preference appearance = findPreference(AppearanceSettingsFragment.class.getSimpleName());
  appearance.setOnPreferenceClickListener(prefClickListener);
  Preference behavior = findPreference(BehaviorSettingsFragment.class.getSimpleName());
  behavior.setOnPreferenceClickListener(prefClickListener);
  Preference storage = findPreference(StorageSettingsFragment.class.getSimpleName());
  storage.setOnPreferenceClickListener(prefClickListener);
  Preference limitations = findPreference(LimitationsSettingsFragment.class.getSimpleName());
  limitations.setOnPreferenceClickListener(prefClickListener);
  Preference network = findPreference(NetworkSettingsFragment.class.getSimpleName());
  network.setOnPreferenceClickListener(prefClickListener);
  Preference scheduling = findPreference(SchedulingSettingsFragment.class.getSimpleName());
  scheduling.setOnPreferenceClickListener(prefClickListener);
  Preference feed = findPreference(FeedSettingsFragment.class.getSimpleName());
  feed.setOnPreferenceClickListener(prefClickListener);
  Preference streaming = findPreference(StreamingSettingsFragment.class.getSimpleName());
  streaming.setOnPreferenceClickListener(prefClickListener);
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the alert dialog.
 */
private void initializeShowAlertDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_alert_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeAlertDialog();
      alertDialog.setShowAnimation(createRectangularRevealAnimation(preference));
      alertDialog.setDismissAnimation(createRectangularRevealAnimation(preference));
      alertDialog.setCancelAnimation(createRectangularRevealAnimation(preference));
      alertDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the progress dialog.
 */
private void initializeShowProgressDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_progress_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeProgressDialog();
      progressDialog.setShowAnimation(createRectangularRevealAnimation(preference));
      progressDialog.setDismissAnimation(createRectangularRevealAnimation(preference));
      progressDialog.setCancelAnimation(createRectangularRevealAnimation(preference));
      progressDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the edit text dialog.
 */
private void initializeShowEditTextDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_edit_text_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeEditTextDialog();
      editTextDialog.setShowAnimation(createRectangularRevealAnimation(preference));
      editTextDialog.setDismissAnimation(createRectangularRevealAnimation(preference));
      editTextDialog.setCancelAnimation(createRectangularRevealAnimation(preference));
      editTextDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Initializes the preference, which allows to show the multiple choice list dialog.
 */
private void initializeShowMultipleChoiceListDialogPreference() {
  Preference preference =
      findPreference(getString(R.string.show_multi_choice_dialog_preference_key));
  preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(final Preference preference) {
      initializeMultipleChoiceListDialog();
      multipleChoiceListDialog
          .setShowAnimation(createRectangularRevealAnimation(preference));
      multipleChoiceListDialog
          .setDismissAnimation(createRectangularRevealAnimation(preference));
      multipleChoiceListDialog
          .setCancelAnimation(createRectangularRevealAnimation(preference));
      multipleChoiceListDialog.show();
      return true;
    }
  });
}

代码示例来源:origin: jruesga/rview

private void configureSearch() {
  mSearchHistoryClear = findPreference(PREF_ACCOUNT_SEARCH_CLEAR);
  mSearchHistoryClear.setOnPreferenceClickListener(this);
  mSearchHistoryClear.setEnabled(Preferences.hasAccountSearchHistory(getContext(), mAccount));
}

代码示例来源:origin: bfabiszewski/ulogger-android

/**
 * Set various listeners
 */
private void setListeners() {
  final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
  final Preference prefUsername = findPreference(KEY_USERNAME);
  final Preference prefPass = findPreference(KEY_PASS);
  final Preference prefHost = findPreference(KEY_HOST);
  // on change listeners
  if (prefLiveSync != null) {
    prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
  }
  if (prefUsername != null) {
    prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
  }
  if (prefPass != null) {
    prefPass.setOnPreferenceChangeListener(serverSetupChanged);
  }
  if (prefHost != null) {
    prefHost.setOnPreferenceChangeListener(serverSetupChanged);
  }
  // on click listeners
  if (prefUsername != null) {
    prefUsername.setOnPreferenceClickListener(serverSetupClicked);
  }
  if (prefHost != null) {
    prefHost.setOnPreferenceClickListener(serverSetupClicked);
  }
}

代码示例来源:origin: KDE/kdeconnect-android

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
  super.onCreatePreferences(savedInstanceState, rootKey);
  PreferenceScreen preferenceScreen = getPreferenceScreen();
  final CheckBoxPreference customDownloads = (CheckBoxPreference) preferenceScreen.findPreference("share_destination_custom");
  filePicker = preferenceScreen.findPreference("share_destination_folder_preference");
  if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)) {
    customDownloads.setOnPreferenceChangeListener((preference, newValue) -> {
      updateFilePickerStatus((Boolean) newValue);
      return true;
    });
    filePicker.setOnPreferenceClickListener(preference -> {
      Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
      startActivityForResult(intent, RESULT_PICKER);
      return true;
    });
  } else {
    customDownloads.setEnabled(false);
    filePicker.setEnabled(false);
  }
  boolean customized = PreferenceManager
      .getDefaultSharedPreferences(requireContext())
      .getBoolean(PREFERENCE_CUSTOMIZE_DESTINATION, false);
  updateFilePickerStatus(customized);
}

代码示例来源:origin: jruesga/rview

private void configureNotifications() {
  // Fetch or join current loader
  if (mNotificationsSupportLoader == null) {
    RxLoaderManager loaderManager = RxLoaderManagerCompat.get(this);
    mNotificationsSupportLoader = loaderManager.create(
        checkNotificationsSupport(), mNotificationsSupportObserver);
  }
  mNotificationsCategory =
      (PreferenceCategory) findPreference(PREF_ACCOUNT_NOTIFICATIONS_CATEGORY);
  mNotificationsAdvise =  findPreference(PREF_ACCOUNT_NOTIFICATIONS_ADVISE);
  mNotificationsAdvise.setOnPreferenceClickListener(this);
  mNotificationsEnabled =  findPreference(Constants.PREF_ACCOUNT_NOTIFICATIONS);
  mNotificationsEvents =  findPreference(Constants.PREF_ACCOUNT_NOTIFICATIONS_EVENTS);
  if (!mAccount.hasAuthenticatedAccessMode()) {
    if (mNotificationsCategory != null) {
      getPreferenceScreen().removePreference(mNotificationsCategory);
      mNotificationsCategory = null;
    }
  } else if (mAccount.hasNotificationsSupport()) {
    enableNotificationsSupport();
  } else {
    // Check notification support to server
    mNotificationsSupportLoader.restart();
  }
}

相关文章