I have a number of EditText fields on an Android app and I've used android:digits to stop invalid characters being input.
eg:
android:digits="@string/validchars"
(where "validchars" is a string resource of all the valid characters - eg A-Z, 0-9, and some punctuation )
The problem is, if the user hits the ENTER key on the soft keyboard it used to take them to the next field but since I added android:digits bit this has stopped working. I've tried adding \n to the validchars
but this just allows Carriage Returns in the single line textboxes (!) so doesn't help. I've tried fiddling with the imeOptions (adding actionNext
etc) but this doesn't seem to fix it either.
I've read about TextWatchers and InputFilters but both seem to be over-complicated for what I'm trying to do and the android:digits
bit works fine in stopping the invalid characters.
Has anyone got any ideas?
I'm using Android SDK version 8 and targeting both 2.2 and 2.3.5 devices.
After a bit of poking around with the attributes available for an EditText I found that when I add android:singleLine="true" the ENTER key now moves the focus to the next field, even when a android:digits is restricting the characters entered. Problem solved! (for me, anyway!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With