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.
Asked
Active
Viewed 731 times
2

Christian
- 25,249
- 40
- 134
- 225
-
hope this will help you https://github.com/santalu/mask-edittext https://github.com/pinball83/Masked-Edittext https://github.com/egslava/edittext-mask – Aniruddh Parihar Sep 06 '18 at 12:12
-
@Pavneet_Singh : While the solution provided here is the same as in the other answers that are linked as doublicate the issue itself isn't. The fact that I'm focused on a specific set of characters that I want to be entered with the UI leaves the possibility open for an UI solution that only shows the user the relevant characters. – Christian Sep 10 '18 at 05:44
1 Answers
2
Use android:digits="1234567890/"
in EditText
- If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. If this is set
SAMPLE CODE
<EditText
android:layout_width="match_parent"
android:digits="1234567890/"
android:inputType="text"
android:layout_height="wrap_content" />

AskNilesh
- 67,701
- 16
- 123
- 163