java类android.preference.Preference的实例源码

MasterChooserSettingsActivity.java 文件源码 项目:tangobot 阅读 19 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
SettingFragment.java 文件源码 项目:3DPrint-Controller 阅读 20 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceClick(Preference preference) {
    switch (preference.getKey()) {

        case CACHE_MAX:
            break;
        case CLEAR_CACHE:
            Toast.makeText(getActivity(), "clear cache", Toast.LENGTH_SHORT).show();
            break;
        case CHECK_UPDATE:
            Toast.makeText(getActivity(), "check update", Toast.LENGTH_SHORT).show();
            break;
        case VERSION_INFO:
            startActivity(new Intent(getActivity(), VersionInfoAct.class));
            break;

        default:
            return false;
    }
    return true;
}
SettingsActivity.java 文件源码 项目:lurkerhn 阅读 25 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
NotificationLightSettings.java 文件源码 项目:lineagex86 阅读 18 收藏 0 点赞 0 评论 0
private void setChildrenStarted(PreferenceGroup group, boolean started) {
    final int count = group.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        Preference pref = group.getPreference(i);
        if (pref instanceof ApplicationLightPreference) {
            ApplicationLightPreference ap = (ApplicationLightPreference) pref;
            if (started) {
                ap.onStart();
            } else {
                ap.onStop();
            }
        } else if (pref instanceof PreferenceGroup) {
            setChildrenStarted((PreferenceGroup) pref, started);
        }
    }
}
SetAlarm_akt.java 文件源码 项目:EsperantoRadio 阅读 24 收藏 0 点赞 0 评论 0
public boolean onPreferenceChange(final Preference p, Object newValue) {
  // Asynchronously save the alarm since this method is called _before_
  // the value of the preference has changed.
  final String ktekstomalnova = ("" + mKanaloPref.getEntry()).trim();
  sHandler.post(new Runnable() {
    public void run() {
      // Editing any preference (except enable) enables the alarm.
      if (p != mEnabledPref) {
        mEnabledPref.setChecked(true);
      }
      if (p == mKanaloPref) {

        String kteksto = ("" + mKanaloPref.getEntry()).trim();
        mKanaloPref.setSummary(kteksto);

        String lteksto = mLabel.getText().toString().trim();
        if (lteksto.length() == 0 || lteksto.equals(ktekstomalnova)) {
          mLabel.setText(kteksto);
        }
      }
      saveAlarm(null);
    }
  });
  return true;
}
SettingsActivity.java 文件源码 项目:MovieGuide 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Binds a preference's summary to its value. More specifically, when the
 * preference's value is changed, its summary (line of text below the
 * preference title) is updated to reflect the value. The summary is also
 * immediately updated upon calling this method. The exact display format is
 * dependent on the type of preference.
 *
 * @see #sBindPreferenceSummaryToValueListener
 */
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference' current value.
    if (preference instanceof ListPreference
            || preference instanceof EditTextPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getString(preference.getKey(), ""));
    } else if (preference instanceof SwitchPreference
            || preference instanceof CheckBoxPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
                PreferenceManager
                        .getDefaultSharedPreferences(preference.getContext())
                        .getBoolean(preference.getKey(),true));
    }
}
AboutChromePreferences.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActivity().setTitle(R.string.prefs_about_chrome);
    addPreferencesFromResource(R.xml.about_chrome_preferences);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        ChromeBasePreference deprecationWarning = new ChromeBasePreference(
                new ContextThemeWrapper(getActivity(),
                        R.style.DeprecationWarningPreferenceTheme));
        deprecationWarning.setOrder(-1);
        deprecationWarning.setTitle(R.string.deprecation_warning);
        deprecationWarning.setIcon(R.drawable.exclamation_triangle);
        getPreferenceScreen().addPreference(deprecationWarning);
    }

    PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
    AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
    Preference p = findPreference(PREF_APPLICATION_VERSION);
    p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
    p = findPreference(PREF_OS_VERSION);
    p.setSummary(versionStrings.getOSVersion());
    p = findPreference(PREF_LEGAL_INFORMATION);
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    p.setSummary(getString(R.string.legal_information_summary, currentYear));
}
RecipientPreferenceActivity.java 文件源码 项目:PeSanKita-android 阅读 25 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
        int          value        = Integer.parseInt((String) newValue);
  final VibrateState vibrateState = VibrateState.fromId(value);

  recipients.setVibrate(vibrateState);

  new AsyncTask<Void, Void, Void>() {
    @Override
    protected Void doInBackground(Void... params) {
      DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
                     .setVibrate(recipients, vibrateState);
      return null;
    }
  }.execute();

  return false;
}
SettingsFragment.java 文件源码 项目:Linphone4Android 阅读 24 收藏 0 点赞 0 评论 0
private void initSettings() {
    initTunnelSettings();
    initAudioSettings();
    initVideoSettings();
    initCallSettings();
    initChatSettings();
    initNetworkSettings();
    initAdvancedSettings();

    findPreference(getString(R.string.pref_add_account_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            int nbAccounts = mPrefs.getAccountCount();
            LinphoneActivity.instance().displayAccountSettings(nbAccounts);
            return true;
        }
    });
}
UserDictionaryList.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Create a single User Dictionary Preference object, with its parameters set.
 * @param localeString The locale for which this user dictionary is for.
 * @return The corresponding preference.
 */
protected Preference createUserDictionaryPreference(@Nullable final String localeString) {
    final Preference newPref = new Preference(getActivity());
    final Intent intent = new Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION);
    if (null == localeString) {
        newPref.setTitle(Locale.getDefault().getDisplayName());
    } else {
        if (localeString.isEmpty()) {
            newPref.setTitle(getString(R.string.user_dict_settings_all_languages));
        } else {
            newPref.setTitle(
                    LocaleUtils.constructLocaleFromString(localeString).getDisplayName());
        }
        intent.putExtra("locale", localeString);
        newPref.getExtras().putString("locale", localeString);
    }
    newPref.setIntent(intent);
    newPref.setFragment(UserDictionarySettings.class.getName());
    return newPref;
}
PreferenceActivity.java 文件源码 项目:AndiCar 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Sets the summary of the preference according to its value
 *
 * @param preference
 * @param value
 */
private static void setPreferenceSummaryByValue(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    }
    else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
}
SettingsActivity.java 文件源码 项目:PretendSharing 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    if(Build.VERSION.SDK_INT>=21)
        setTheme(R.style.Material);
    else if (Build.VERSION.SDK_INT>=11)
        setTheme(R.style.Holo);
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference_settings);
    findPreference("disable_qq").setOnPreferenceChangeListener(new disabler("QQActivity"));
    findPreference("disable_wechat").setOnPreferenceChangeListener(new disabler("WechatActivity"));
    findPreference("disable_generic").setOnPreferenceChangeListener(new disabler("GenericActivity"));
    findPreference("disable_this").setOnPreferenceChangeListener(new disabler("JumpActivity"));
    findPreference("show_help").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            startActivity(new Intent(SettingsActivity.this, GuideActivity.class));
            return true;
        }
    });
}
DoNotTrackPreference.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 19 收藏 0 点赞 0 评论 0
@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;
        }
    });
}
DevelopmentSettingsActivity.java 文件源码 项目:DeveloperSettings 阅读 15 收藏 0 点赞 0 评论 0
private void updateDebugHwOverdraw() {
    final CharSequence[] entries = mDebugHwOverdrawPref.getEntries();
    String value = SystemProperties.get(Constants.THREADED_RENDERER_DEBUG_OVERDRAW_PROPERTY);
    int idxOfValue = mDebugHwOverdrawPref.findIndexOfValue(value);
    if (idxOfValue != -1) {
        mDebugHwOverdrawPref.setValueIndex(idxOfValue);
        mDebugHwOverdrawPref.setSummary(entries[idxOfValue]);
    }

    mDebugHwOverdrawPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // ThreadedRenderer.DEBUG_OVERDRAW_PROPERTY
            String command = String.format("setprop %s %s",
                    Constants.THREADED_RENDERER_DEBUG_OVERDRAW_PROPERTY,
                    newValue.toString());
            ShellUtils.execCommand(command, true);
            new SystemPropPoker().execute();

            int indexOfValue = mDebugHwOverdrawPref.findIndexOfValue(newValue.toString());
            preference.setSummary(entries[indexOfValue]);

            return true;
        }
    });
}
SettingsActivity.java 文件源码 项目:Calendouer 阅读 27 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
AccountPreferencesFragment.java 文件源码 项目:Linphone4Android 阅读 23 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String value = newValue.toString();
    try {
        int intValue = Integer.parseInt(value);
        if ((intValue < 1) || (intValue > 5)) {
            return false;
        }
    } catch (NumberFormatException nfe) { }
    if (isNewAccount) {
        //TODO
    } else {
        mPrefs.setAvpfRRInterval(n, value);
    }
    preference.setSummary(value);
    return true;
}
CorrectionSettingsFragment.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 15 收藏 0 点赞 0 评论 0
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {
    final Activity activity = getActivity();
    final TreeSet<String> localeList = UserDictionaryList.getUserDictionaryLocalesSet(activity);
    if (null == localeList) {
        // The locale list is null if and only if the user dictionary service is
        // not present or disabled. In this case we need to remove the preference.
        getPreferenceScreen().removePreference(userDictionaryPreference);
    } else if (localeList.size() <= 1) {
        userDictionaryPreference.setFragment(UserDictionarySettings.class.getName());
        // If the size of localeList is 0, we don't set the locale parameter in the
        // extras. This will be interpreted by the UserDictionarySettings class as
        // meaning "the current locale".
        // Note that with the current code for UserDictionaryList#getUserDictionaryLocalesSet()
        // the locale list always has at least one element, since it always includes the current
        // locale explicitly. @see UserDictionaryList.getUserDictionaryLocalesSet().
        if (localeList.size() == 1) {
            final String locale = (String)localeList.toArray()[0];
            userDictionaryPreference.getExtras().putString("locale", locale);
        }
    } else {
        userDictionaryPreference.setFragment(UserDictionaryList.class.getName());
    }
}
DictionarySettingsFragment.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 23 收藏 0 点赞 0 评论 0
void refreshInterface() {
    final Activity activity = getActivity();
    if (null == activity) return;
    final PreferenceGroup prefScreen = getPreferenceScreen();
    final Collection<? extends Preference> prefList =
            createInstalledDictSettingsCollection(mClientId);

    activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // TODO: display this somewhere
                // if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
                refreshNetworkState();

                removeAnyDictSettings(prefScreen);
                int i = 0;
                for (Preference preference : prefList) {
                    preference.setOrder(i++);
                    prefScreen.addPreference(preference);
                }
            }
        });
}
LedMainActivity.java 文件源码 项目:GravityBox 阅读 16 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceTreeClick(PreferenceScreen prefScreen, Preference pref) {
    final String key = pref.getKey();
    if (PREF_KEY_DEFAULT_SETTINGS.equals(key)) {
        Intent intent = new Intent(getActivity(), LedSettingsActivity.class);
        intent.putExtra(LedSettingsActivity.EXTRA_PACKAGE_NAME, "default");
        intent.putExtra(LedSettingsActivity.EXTRA_APP_NAME,
                getString(R.string.lc_activity_menu_default_settings));
        startActivity(intent);
    } else if (PREF_KEY_PERAPP_SETTINGS.equals(key)) {
        startActivity(new Intent(getActivity(), LedControlActivity.class));
    } else if (PREF_KEY_ACTIVE_SCREEN.equals(key)) {
        startActivity(new Intent(getActivity(), ActiveScreenActivity.class));
    } else if (PREF_KEY_QUIET_HOURS.equals(key)) {
        startActivity(new Intent(getActivity(), QuietHoursActivity.class));
    }
    return super.onPreferenceTreeClick(prefScreen, pref);
}
MainSettingsActivity.java 文件源码 项目:PretendSharing_Xposed 阅读 18 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    try {
        ComponentName targetActivity = new ComponentName(packageName, ActivityName);
        PackageManager p = getPackageManager();
        if ((boolean) newValue) {
            p.setComponentEnabledSetting(targetActivity, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
        } else {
            p.setComponentEnabledSetting(targetActivity, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
        }
    }catch (Exception e){
        Toast.makeText(MainSettingsActivity.this,R.string.disable_error,Toast.LENGTH_SHORT).show();
        return false;
    }
    return true;
}
AccountFragment.java 文件源码 项目:School1-Android 阅读 32 收藏 0 点赞 0 评论 0
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.account);
    //SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

    //findPreference("userName").setSummary(sharedPreferences.getString("userName", "Add a user name"));
    //findPreference("schoolName").setSummary(sharedPreferences.getString("schoolName", "Add a school name"));

    findPreference("actionChangeUser").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            FirebaseAuth.getInstance().signOut();
            startActivity(new Intent(getActivity(), SigninActivity.class));
            return true;
        }
    });
}
TwoStatePreferenceHelper.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 19 收藏 0 点赞 0 评论 0
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
        final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
            }
        }
    }
}
AutofillPreferences.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 19 收藏 0 点赞 0 评论 0
private void rebuildCreditCardList() {
    PreferenceGroup profileCategory =
            (PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
    profileCategory.removeAll();
    for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(card.getObfuscatedNumber());
        pref.setSummary(card.getFormattedExpirationDate(getActivity()));

        if (card.getIsLocal()) {
            pref.setFragment(AutofillLocalCardEditor.class.getName());
        } else {
            pref.setFragment(AutofillServerCardEditor.class.getName());
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, card.getGUID());
        profileCategory.addPreference(pref);
    }
}
AccountsSettingsFragment.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 21 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceClick(final Preference preference) {
    final AlertDialog confirmationDialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.clear_sync_data_title)
            .setMessage(R.string.clear_sync_data_confirmation)
            .setPositiveButton(R.string.clear_sync_data_ok,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            if (which == DialogInterface.BUTTON_POSITIVE) {
                                AccountStateChangedListener.forceDelete(
                                        getSignedInAccountName());
                            }
                        }
                     })
            .setNegativeButton(R.string.cloud_sync_cancel, null /* OnClickListener */)
            .create();
    confirmationDialog.show();
    return true;
}
AutofillPreferences.java 文件源码 项目:chromium-for-android-56-debug-video 阅读 20 收藏 0 点赞 0 评论 0
private void rebuildProfileList() {
    // Add an edit preference for each current Chrome profile.
    PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
    profileCategory.removeAll();
    for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(profile.getFullName());
        pref.setSummary(profile.getLabel());

        if (profile.getIsLocal()) {
            pref.setFragment(AutofillProfileEditor.class.getName());
        } else {
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
            pref.setFragment(AutofillServerProfilePreferences.class.getName());
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, profile.getGUID());
        profileCategory.addPreference(pref);
    }
}
SettingsActivity.java 文件源码 项目:Botanist 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Run when fragment is created
 * @param savedInstanceState - current fragment state
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    Preference timePicker = findPreference("water_time");
    timePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        /**
         * User clicked an option
         * @param preference - selected option
         * @return Returns false
         */
        @Override
        public boolean onPreferenceClick(Preference preference) {
            showTimePicker();
            return false;
        }
    });
    updatePref(WATER_REMINDER_KEY);
    updatePref(HEIGHT_REMINDER_KEY);
    updatePref(PHOTO_REMINDER_KEY);
    updatePref(FERTILIZER_REMINDER_KEY);
}
SettingsFragment.java 文件源码 项目:Ships 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    final Preference button = (Preference) findPreference(getString(R.string.pref_rtlSdrPpmInvalidate));
    button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            useOtherRtlSdrDeviceAreYouSure();
            return true;
        }
    });
}
SettingFragment.java 文件源码 项目:Musicoco 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_general);

    as = AutoSwitchThemeController.getInstance(getActivity());

    findPreference("pre_auto_switch_night_theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            checkAutoThemeSwitch();
            return false;
        }
    });

}
ChatsPreferenceFragment.java 文件源码 项目:PeSanKita-android 阅读 19 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceClick(Preference preference) {
  final int threadLengthLimit = TextSecurePreferences.getThreadTrimLength(getActivity());
  AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  builder.setTitle(R.string.ApplicationPreferencesActivity_delete_all_old_messages_now);
  builder.setMessage(getResources().getQuantityString(R.plurals.ApplicationPreferencesActivity_this_will_immediately_trim_all_conversations_to_the_d_most_recent_messages,
                                                      threadLengthLimit, threadLengthLimit));
  builder.setPositiveButton(R.string.ApplicationPreferencesActivity_delete,
    new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        Trimmer.trimAllThreads(getActivity(), threadLengthLimit);
      }
    });

  builder.setNegativeButton(android.R.string.cancel, null);
  builder.show();

  return true;
}
SettingActivity.java 文件源码 项目:QuakeRepor 阅读 32 收藏 0 点赞 0 评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            CharSequence[] labels  = listPreference.getEntries();
            preference.setSummary(labels[prefIndex]);
        }

    }else {
        preference.setSummary(stringValue);
    }
    return true;
}


问题


面经


文章

微信
公众号

扫码关注公众号