Java Code Examples for androidx.preference.EditTextPreference#setOnBindEditTextListener()

The following examples show how to use androidx.preference.EditTextPreference#setOnBindEditTextListener() . 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: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
private void createEncoderBitRatePreference() {
    EditTextPreference pref = findPreference("encoder_bit_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " Mbps"
        );
        // 0以上の実数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_DECIMAL));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Settings.DEFAULT_ENCODER_BITRATE_BASE);
        }
    }
}
 
Example 2
Source File: SettingsActivity.java    From Hauk with Apache License 2.0 5 votes vote down vote up
private static void setTextEditParams(PreferenceManager manager, info.varden.hauk.system.preferences.Preference<?> preference, EditTextPreference.OnBindEditTextListener... listeners) {
    EditTextPreference pref = manager.findPreference(preference.getKey());
    if (pref != null) {
        pref.setOnBindEditTextListener(new CascadeBindListener(listeners));
    } else {
        Log.wtf("Could not find setting for preference %s setting OnBindEditTextListener", preference); //NON-NLS
    }
}
 
Example 3
Source File: RtspPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void setInputTypeNumber(int resId) {
    EditTextPreference editTextPreference = findPreference(getString(resId));
    if (editTextPreference != null) {
        editTextPreference.setOnBindEditTextListener((editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED));
        editTextPreference.setOnPreferenceChangeListener(mOnPreferenceChangeListener);
    }
}
 
Example 4
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void setInputTypeNumber(String key) {
    EditTextPreference editTextPreference = findPreference(key);
    if (editTextPreference != null) {
        editTextPreference.setOnBindEditTextListener((editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED));
        editTextPreference.setOnPreferenceChangeListener(mOnPreferenceChangeListener);
    }
}
 
Example 5
Source File: SettingsPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void createEncoderFrameRatePreference() {
    EditTextPreference pref = findPreference("encoder_frame_rate");
    if (pref != null) {
        pref.setSummaryProvider((Preference preference) ->
                pref.getText() + " fps"
        );
        // 0以上の整数値以外の入力を禁止する
        pref.setOnBindEditTextListener((@NonNull EditText editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER));
        String value = pref.getText();
        if (value == null) {
            pref.setText(Integer.toString(Settings.DEFAULT_ENCODER_FPS));
        }
    }
}
 
Example 6
Source File: SRTSettingPreferenceActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
private void setInputTypeNumber(String key) {
    EditTextPreference editTextPreference = findPreference(key);
    if (editTextPreference != null) {
        editTextPreference.setOnBindEditTextListener((editText) ->
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED));
        editTextPreference.setOnPreferenceChangeListener(mOnPreferenceChangeListener);
    }
}