I need the user to enter text in a Edit Text with custom keyboard options. That is, I need the keypad to show only "S","A","B","C","D","E" and "F" characters. Is it possible to implement this?
Asked
Active
Viewed 8,841 times
7
-
You can create your own Layout for keypad with your needs...and open it as custom dialog. – Chirag Ghori Jan 18 '14 at 06:48
-
1Refer this : http://stackoverflow.com/questions/1858950/set-custom-keyboard-for-android-application – Hardik Joshi Jan 18 '14 at 06:50
1 Answers
6
Much easier solution is to add digit parameter in xml definition of EditText like following:
android:digits="SABCDEF"
android:inputType="textNoSuggestions"
Shown keyboard will have all characters but when user try to enter any of not allowed that will be ignored.
Hope this helps
Edit: textNosuggestions to textNoSuggestions
-
1
-
in my opinion there is no reason for that. You don't want to change in runtime what user can enter in one text field – Ewoks Apr 16 '16 at 08:42
-
I make the field of editTexts dynamically. So I need it. The application creates matrix, the input can be only 1234567890./- . But I cant find solution for this combination. – Dominika Apr 16 '16 at 08:50
-
cell.setInputType(InputType.TYPE_CLASS_NUMBER); But it is not all I wanted. The / is missing. – Dominika Apr 16 '16 at 08:51
-
1Once again I strongly advice that you define your EditText in xml not in a runtime. Debugging such a created UI can be real pain (from my own experience), and in 99% cases there is no reason to create Views in runtime like that.. If you really want to do it so maybe this would help .setKeyListener(DigitsKeyListener.getInstance("0123456789./-")); – Ewoks Apr 16 '16 at 09:10
-
-
Pay attention to whole comment again and try to define Views in xml please. – Ewoks Apr 16 '16 at 09:13
-
I see. Dimension of matrix is setup in runtime. Based on input from user. So thats why I create also field of ediTexts dynamically . I dont know, how to set editTexts dynamically in xml. Do you have any advice? – Dominika Apr 16 '16 at 09:17