1

I have an editText preference in my Settings Activity. I want to get a number from 0-99 from the user. How can i do that?

<EditTextPreference
    android:defaultValue="90"
    android:key="key_a"
    android:inputType="number"
    android:title="@string/pref_title"/>

Using this code i have restricted the input to numbers,but i want to further restrict the user from entering more than 2 digits.

If restriction is not possible,any validation method to check if the entered input is <= 99 and if the entered input is invalid, i would like to change the value to its previously saved value.

1 Answers1

1

Adding android:maxLength="2" solved it. Thanks @Suraj Nair