Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a minimum and maximum value for android edit text preference

I was wondering if there is a way to enforce a minimum value for the edit text preference.

Here's my node for the EditTextPreference in the preference screen xml file:

    <EditTextPreference
    android:id="@+id/txt_slideshow_speed"
    android:key="@string/prefSlideShowSpeedKey"
    android:persistent="true"
    android:inputType="number"
    android:max="3600"
    android:dialogTitle="Slideshow Speed (seconds)"
    android:defaultValue="@string/defaultSlideShowSpeedValue"
    android:title="Slideshow Speed" />
like image 722
Rohaan Avatar asked Nov 05 '25 17:11

Rohaan


1 Answers

First, you will need to get the EditText programmatically via getEditText(). Then, check out this link to set an input filter on your EditText.

like image 65
Mike Ortiz Avatar answered Nov 08 '25 11:11

Mike Ortiz