0

I need a editText input type that allows me to increase the experience of the user when he/she is entering a bank account or bank branch. The numbers should follow those rules:

Account: \d{1,5}-\d{1,2}|X --> one to five numeric digits, dash, one or two numeric digits or one X character

Branch: \d{1,5}(-\d{1,2}|-X)? --> one to five numeric digits, dash, zero, one or two numeric digits or one X character

As my entry have likely more numeric digits I want the keyboard to offer numbers primarily, and if the user have a X digit he/she can swap the input type. Basically I want a keyboard whose symbolic layout is displayed first.

UPDATE:

I tried changing the input type in the edit text xml:

<EditText
    style="@style/Subhead.Form"
    android:inputType="text"
    android:maxLength="7"
    app:hint="@{@string/profile_hint_bankBranch}"
    app:bindTo="@{viewModel.branch.input}"
    tools:text="1234-5"/>

But this presents the text layout first, as expected, I also tried several other options but I think that none does what I want.

In iOS I'm using the "Numbers and punctuation" keyboard type, that does exactly what I want, is there any easy solution to have the same behaviour?

Felipe Jun
  • 722
  • 11
  • 22
  • Please show the code you've tried to implement this, and state specifically where you are getting stuck. – NoChinDeluxe Apr 19 '16 at 18:27
  • I updated with my xml file, I tried this guy's solution http://stackoverflow.com/a/29175373/1080583 but I dont want something so fancy, just presenting the symbolic keyboard as default would be fine – Felipe Jun Apr 19 '16 at 21:00

1 Answers1

0

You can use the "phone" inputType on your edittext. This will reduce the keyboard to numbers and dashes. http://developer.android.com/training/keyboard-input/style.html

For more fancy stuff (regex-check, autocomplete, changing keyboard style) you will have to resort to something like a custom text change listener. http://developer.android.com/reference/android/widget/TextView.html#addTextChangedListener(android.text.TextWatcher)

J. Dow
  • 563
  • 3
  • 13
  • Just numbers and dashes are not sufficient, I also need the X character, the phone input type have letters on the number keys but I did not manage to access them as type options – Felipe Jun Apr 19 '16 at 20:57