Java Code Examples for android.support.v7.preference.EditTextPreference#setOnPreferenceChangeListener()

The following examples show how to use android.support.v7.preference.EditTextPreference#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: SettingsFragment.java    From android_gisapp with GNU General Public License v3.0 6 votes vote down vote up
public static void initializeAccurateTaking(EditTextPreference accurateMaxCount)
{
    accurateMaxCount.setSummary(accurateMaxCount.getText());

    accurateMaxCount.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(
                Preference preference,
                Object newValue)
        {
            preference.setSummary((CharSequence) newValue);
            return true;
        }
    });
}
 
Example 2
Source File: SettingsFragment.java    From nevo-decorators-sms-captchas with GNU General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example 3
Source File: SettingsActivity.java    From video-quickstart-android with MIT License 5 votes vote down vote up
private void setupSenderBandwidthPreferences(String key,
                                             String defaultValue,
                                             EditTextPreference editTextPreference) {
    String value = sharedPreferences.getString(key, defaultValue);

    // Set layout with input type number for edit text
    editTextPreference.setDialogLayoutResource(R.layout.preference_dialog_number_edittext);
    editTextPreference.setSummary(value);
    editTextPreference.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary(newValue.toString());
        return true;
    });
}
 
Example 4
Source File: SettingFragment.java    From ChipHellClient with Apache License 2.0 5 votes vote down vote up
private void setForumAddress() {
    mForumAddress = (EditTextPreference) findPreference(GlobalSetting.FORUM_ADDRESS);
    String forumAddress = GlobalSetting.getForumAddress();
    mForumAddress.setSummary(forumAddress);
    mForumAddress.setText(forumAddress);
    mForumAddress.setOnPreferenceChangeListener(this);
}