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

The following examples show how to use androidx.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: 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 2
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 3
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);
    }
}
 
Example 4
Source File: DnsServerConfigFragment.java    From Daedalus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    EditTextPreference serverName = findPreference("serverName");
    serverName.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });

    EditTextPreference serverAddress = findPreference("serverAddress");
    serverAddress.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });

    EditTextPreference serverPort = findPreference("serverPort");
    serverPort.setOnPreferenceChangeListener((preference, newValue) -> {
        preference.setSummary((String) newValue);
        return true;
    });


    index = intent.getIntExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE);
    if (index != ConfigActivity.ID_NONE) {
        CustomDnsServer server = Daedalus.configurations.getCustomDNSServers().get(index);
        serverName.setText(server.getName());
        serverName.setSummary(server.getName());
        serverAddress.setText(server.getAddress());
        serverAddress.setSummary(server.getAddress());
        serverPort.setText(String.valueOf(server.getPort()));
        serverPort.setSummary(String.valueOf(server.getPort()));
    } else {
        serverName.setText("");
        serverAddress.setText("");
        String port = String.valueOf(DnsServer.DNS_SERVER_DEFAULT_PORT);
        serverPort.setText(port);
        serverPort.setSummary(port);
    }
    return view;
}