If you really need one input type for your editTextPreference, you can set it in XML using android: inputType = "number" or android: inputType = "numberDecimal".
Example:
<EditTextPreference android:defaultValue="130" android:dialogMessage="@string/upper_limit_hint" android:dialogTitle="@string/upper_limit_text" android:inputType="number" android:key="UPPER_LIMIT" android:maxLength="4" android:summary="@string/upper_limit_hint" android:title="@string/upper_limit_text" />
Also, higher than Dave's suggestion above, I was able to achieve this programmatically by assigning EditTextPreference to the TextView (I could not use EditText).
Example:
EditTextPreference editTextPreference = (EditTextPreference) preference; TextView etpTextView = (TextView) editTextPreference.getEditText(); // If I want entry with decimal capability etpTextView.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); // or if I want entry without decimal capability etpTextView.setInputType(InputType.TYPE_CLASS_NUMBER);
William bell
source share