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

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

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

Preference.setOnPreferenceClickListener介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

importDataPreference.setOnPreferenceClickListener((Preference p) -> {
  Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
      .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
exportDataPreference.setOnPreferenceClickListener((Preference p) -> {
  Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
      .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)

代码示例来源:origin: woefe/ShoppingList

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  final Preference fileLocationPref = findPreference("FILE_LOCATION");
  fileLocationPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      Intent intent = new Intent(getContext(), DirectoryChooser.class);
      startActivityForResult(intent, REQUEST_CODE_CHOOSE_DIR);
      return true;
    }
  });
}

代码示例来源:origin: kizitonwose/colorpreference

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
  addPreferencesFromResource(R.xml.pref_compat);
  findPreference(CUSTOM_PICKER_PREF_KEY).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      showColorDialog(preference);
      return true;
    }
  });
}

代码示例来源:origin: kollerlukas/Camera-Roll-Android-App

private void initExcludedPathsPref() {
  Preference pref = findPreference(getString(R.string.pref_key_excluded_paths));
  pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      if (callback != null) {
        callback.onSettingChanged();
      }
      Intent intent = new Intent(getContext(), ExcludePathsActivity.class);
      getContext().startActivity(intent);
      return false;
    }
  });
}

代码示例来源:origin: kollerlukas/Camera-Roll-Android-App

private void initVirtualDirectoriesPref() {
  Preference pref = findPreference(getString(R.string.pref_key_virtual_directories));
  pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      if (callback != null) {
        callback.onSettingChanged();
      }
      Intent intent = new Intent(getContext(), VirtualAlbumsActivity.class);
      getContext().startActivity(intent);
      return false;
    }
  });
}

代码示例来源:origin: markusfisch/ShaderEditor

@Override
public void onCreatePreferences(Bundle state, String rootKey) {
  addPreferencesFromResource(R.xml.preferences);
  Preference importPreference = findPreference(
      Preferences.IMPORT_FROM_DIRECTORY);
  importPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      if (checkExternalStoragePermission(
          READ_EXTERNAL_STORAGE_REQUEST,
          Manifest.permission.READ_EXTERNAL_STORAGE)) {
        ImportExport.importFromDirectory(getContext());
      }
      return true;
    }
  });
  Preference exportPreference = findPreference(
      Preferences.EXPORT_TO_DIRECTORY);
  exportPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      if (checkExternalStoragePermission(
          WRITE_EXTERNAL_STORAGE_REQUEST,
          Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        ImportExport.exportToDirectory(getContext());
      }
      return true;
    }
  });
}

代码示例来源:origin: fgl27/isu

private void updateStateNoInternet() {
  mUpdate.setSummary(getString(R.string.update_summary_fail));
  mUpdate.setIcon(R.drawable.interrogation);
  mUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      updateStateCheck();
      return true;
    }
  });
}

代码示例来源:origin: cachapa/AerialDream

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
  setPreferencesFromResource(R.xml.settings, rootKey);
  findPreference("system_options").setOnPreferenceClickListener(this);
  getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  updateSummaries();
}

代码示例来源:origin: UdacityAndroidDevScholarship/quiz-app

private void setupPreferences(int prefCount, PreferenceCategory category) {
  for (int i = 0; i < prefCount; i++) {
    Preference p = category.getPreference(i);
    if (!(p instanceof SwitchPreference)) {
      String value = preferences.getString(p.getKey(), "");
      setPreferenceSummary(p, value);
    }
  }
  Preference signOut = findPreference(getResources().getString(R.string.sign_out_key));
  signOut.setOnPreferenceClickListener(preference -> {
    showSignOutAlert();
    return true;
  });
}

代码示例来源:origin: fgl27/isu

private void updateStateMasked(boolean useHide) {
  if (useHide) {
    mUpdate.setSummary(getString(R.string.update_use_hide));
    mUpdate.setIcon(R.drawable.interrogation);
    mUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
      @Override
      public boolean onPreferenceClick(Preference preference) {
        Tools.DoAToast(getString(R.string.update_use_hide), getActivity());
        return true;
      }
    });
  } else {
    mUpdate.setSummary(String.format(getString(R.string.update_summary_out), version) + " " + BuildConfig.VERSION_NAME + getString(R.string.update_link));
    mUpdate.setIcon(R.drawable.warning);
    mUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
      @Override
      public boolean onPreferenceClick(Preference preference) {
        Tools.browser(link, getActivity());
        return true;
      }
    });
  }
}

代码示例来源:origin: bertrandmartel/youtubetv

@Override
public void onResume() {
  super.onResume();
  Preference infoPrefs = frag.findPreference("info_version");
  infoPrefs.setSummary(BuildConfig.VERSION_NAME);
  Preference license = frag.findPreference("license");
  license.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      WebDialogFragment dialog = WebDialogFragment.newInstance("file:///android_asset/license.html", getActivity().getString(R.string.dialog_title_license));
      dialog.show(getFragmentManager(), getActivity().getString(R.string.dialog_title_license));
      return false;
    }
  });
}

代码示例来源:origin: NianguoWang/ZhihuReader-master

findPreference("no_picture_mode").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {
findPreference("in_app_browser").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {
findPreference("clear_image_cache").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {

代码示例来源:origin: GrossumUA/TAS_Android_Boilerplate

private void initPrefs() {
  findPreference(getString(R.string.id_pref_logout)).setOnPreferenceClickListener(this);
  Preference switchBackgroundJob = findPreference(getString(R.string.id_pref_switcher));
  switchBackgroundJob.setOnPreferenceChangeListener(this);
  switchBackgroundJob.setEnabled(getArguments().getBoolean(AUTOLOGIN_ENABLED_ARGS));
}

代码示例来源:origin: fgl27/isu

mUpdate.setSummary(getString(R.string.update_summary_up));
mUpdate.setIcon(R.drawable.ok);
mUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference preference) {

代码示例来源:origin: marzika/Snapprefs

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

代码示例来源:origin: JBossOutreach/lead-management-android

login.setOnPreferenceClickListener(preference -> {
  signIn();
  return true;
});
signOut.setOnPreferenceClickListener( preference ->  {
  signOut();
  return true;

代码示例来源:origin: xbmc/Kore

/**
   * Sets up the preferences state and summaries
   */
  private void setupPreferences() {
    // Theme preferences
    ListPreference themePref = (ListPreference)findPreference(Settings.KEY_PREF_THEME);
    themePref.setSummary(themePref.getEntry());

    // About preference
    String nameAndVersion = getActivity().getString(R.string.app_name);
    try {
      nameAndVersion += " " +
          getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException exc) {
    }
    Preference aboutPreference = findPreference(Settings.KEY_PREF_ABOUT);
    aboutPreference.setSummary(nameAndVersion);
    aboutPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
      @Override
      public boolean onPreferenceClick(Preference preference) {
        AboutDialogFragment aboutDialog = new AboutDialogFragment();
        aboutDialog.show(getFragmentManager(), null);
        return true;
      }
    });
  }
}

代码示例来源:origin: Kr328/nevo-decorators-sms-captchas

@Override
public void onCreatePreferences(Bundle bundle, String s) {
  addPreferencesFromResource(R.xml.main_setting);
  getPreferenceScreen().setEnabled(false);
  mCaptchaHideOnLocked           = (CheckBoxPreference) findPreference(Settings.SETTING_CAPTCHA_HIDE_ON_LOCKED);
  mCaptchaOverrideDefaultAction  = (CheckBoxPreference) findPreference(Settings.SETTING_CAPTCHA_OVERRIDE_DEFAULT_ACTION);
  mCaptchaPostCopyAction         = (ListPreference)     findPreference(Settings.SETTING_CAPTCHA_POST_COPY_ACTION);
  mCaptchaIdentifyPattern        = (EditTextPreference) findPreference(Settings.SETTING_CAPTCHA_IDENTIFY_PATTERN);
  mCaptchaParsePattern           = (EditTextPreference) findPreference(Settings.SETTING_CAPTCHA_PARSE_PATTERN);
  mSubscribeIdentityPattern      = (EditTextPreference) findPreference(Settings.SETTING_SUBSCRIBE_IDENTIFY_PATTERN);
  mSubscribePriority             =                      findPreference(Settings.SETTING_SUBSCRIBE_PRIORITY);
  mHideInLauncher                = (CheckBoxPreference) findPreference(KEY_HIDE_IN_LAUNCHER);
  mCaptchaHideOnLocked.setOnPreferenceChangeListener(this::onPreferenceChange);
  mCaptchaOverrideDefaultAction.setOnPreferenceChangeListener(this::onPreferenceChange);
  mCaptchaPostCopyAction.setOnPreferenceChangeListener(this::onPreferenceChange);
  mCaptchaIdentifyPattern.setOnPreferenceChangeListener(this::onPreferenceChange);
  mCaptchaParsePattern.setOnPreferenceChangeListener(this::onPreferenceChange);
  mSubscribeIdentityPattern.setOnPreferenceChangeListener(this::onPreferenceChange);
  mHideInLauncher.setOnPreferenceChangeListener(this::onPreferenceChange);
  mSubscribePriority.setOnPreferenceChangeListener(this::onPreferenceChange);
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
    mSubscribePriority.setOnPreferenceClickListener((Preference p) -> {
      startActivity(
          new Intent("android.settings.APP_NOTIFICATION_SETTINGS").
              putExtra("android.provider.extra.APP_PACKAGE" , Global.NEVOLUTION_PACKAGE_NAME));
      return false;
    });
  }
  new Thread(this::loadSettingsAndUpdateViews).start();
}

代码示例来源:origin: marzika/Snapprefs

@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getPreferenceManager().setSharedPreferencesMode(Context.MODE_WORLD_READABLE);
  addPreferencesFromResource(preferenceId);
  Preference pref = findPreference("pref_key_launcher");
  pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
      PackageManager packageManager = getActivity().getPackageManager();
      int state = (Boolean) newValue ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
      ComponentName aliasName = new ComponentName(getActivity(), "com.marz.snapprefs.MainActivity-Alias");
      packageManager.setComponentEnabledSetting(aliasName, state, PackageManager.DONT_KILL_APP);
      return true;
    }
  });
  final LayoutInflater inflater = getLayoutInflater(savedInstanceState);
  Preference debugOptions = findPreference("pref_key_debug_options");
  debugOptions.setOnPreferenceClickListener(new OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
      displayDebugMenu(inflater);
      return false;
    }
  });
}

代码示例来源:origin: vitas/beaconloc

testButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
  @Override
  public boolean onPreferenceClick(Preference arg0) {

相关文章