androidandroid-inputtype

Android textinput where the user can write digits and '/'


My user has to enter a string like 21/99 where digits and the sign / are the only valid signs that the user can enter, ideally those would all be shown on the keyboard and little other signs. Unfortunately, neither number nor text not any other type I found produces in such an UI. Is there a way where I can make it easy for my user to enter such numbers.


Solution

  • Use android:digits="1234567890/" in EditText

    android:digits

    SAMPLE CODE

    <EditText
        android:layout_width="match_parent"
        android:digits="1234567890/"
        android:inputType="text"
        android:layout_height="wrap_content" />