Android: EditText not allow special characters with Next softkey - android

I have an EditText which is required to accept only alphanumeric characters. No any special ones allowed (such as: Á, Â...)
I added some properties:
android:inputType="text|textCapCharacters|textFilter"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
android:imeOptions="flagNavigateNext"
android:nextFocusLeft="#+id/txtYearOfBirth"
android:nextFocusUp="#+id/txtYearOfBirth"
android:nextFocusRight="#+id/txtFirstName"
android:nextFocusDown="#+id/txtFirstName"
It worked fine for no special characters but the soft key Next is replaced by Enter:
How can I keep the Next button instead?
Thank you very much for any help.

Use these following properties of EditText and check
android:maxLines="1"
android:singleLine="true"

Related

how to remove emoji in edittext password fields

When inputtype is used as textPassword, user was able to entire emoji in edit text. If I use both textpassword and textEmailAddress, then passwords are visible. Is there any easy way to achieve this without using textwatcher. The password field can allow other special characters also.
Please note that I am trying to remove emoji by setting the input type. I am not looking for solutions with regular expressions/textwatcher/filters. If the field is not password type I would have used textEmailAddress to avoid emoji option on keyboard
This allow character only a to z and A to Z :
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
android:inputType="textPassword"/>
Use this in your Password EditText XML file
android:inputType="textPassword|text"
Look more about input methods here
Also, you can use RegularExpression to check whether your password is valid or not.

How to allow Multiline Text in Android EditText while restricting input using android:digits?

With an EditText it is possible to add an entry to support alphanumeric digits like the following:
android:digits="#string/alphanumeric_allowed_chars_free_textentry"
Where the string is defined as
<string name="alphanumeric_allowed_chars_free_textentry">
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=[];,./~!##$%^</string>
However, as others have noted, when a user sets the digits attribute, it can cause the "enter" button to show a return arrow instead of a next or done button, as described in this related question
The typical solution to get done to show up is to set android:singleLine="true" and android:imeOptions="actionDone", but this will only work for an input box which is not a multi-line box. I have a multi-line edit text and would like to be able to add a done button and also fliter using the digits attribute.
Does anyone know how to allow an EditText to use digits while also being multiline, while also allowing the return button to show "done"? Android 4.4
What if you modify alphanumeric_allowed_chars_free_textentry to include carriage return (\r, \n)?
i was unable to reply / comment to your comment
So added new answer
in multiline edittext
after adding \r\n to my digits property
android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\"
i am able to goto nextline on enter as well using the digits property.
below is my axml code "
i was unable to reply / comment to your comment
in multiline edittext after adding \r\n to my digits property android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\"
i am able to goto nextline as well using the digits property .
"
<EditText
android:id="#+id/NewTask_TaskDescription"
style="#style/MultiLineTextboxStyle"
android:layout_marginBottom="10dp"
android:layout_height="151dp"
android:layout_width="match_parent"
android:inputType="textCapSentences|textMultiLine"
android:singleLine="false"
android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\\" />
"

Soft keyboard with comma instead of dot for decimal separator in android

I have been reading some threads about this problem and some are not answered and others (from 2011) explain how this was a known bug.
Has this been solved? Is it possible right now to show soft keyboard with culture information? I would like to show a decimal keyboard showing a "," instead of a "dot" for the decimal separator.
You can use the following workaround to also include comma as a valid input:-
Through XML:
<EditText
android:inputType="number"
android:digits="0123456789.," />
Programmatically:
EditText input = new EditText(THE_CONTEXT);
input.setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));
In this way Android system will show the numbers' keyboard and allow the input of comma. Hope it helps :)
It is not possible to not show the '.' in the soft keyboard without creating your own one.
The solution than I found is:
<EditText
android:inputType="numberDecimal"
android:digits="0123456789," />
This way when you press the '.' in the soft keyboard nothing happens; only numbers and comma are allowed
I solved this by extending NumberKeyListener to accept ',' and '.',
and overrode:
#Override
public int getInputType() {
return InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED;
}
Furthermore I set a TextWatcher on the EditText, which replaced all '.' with ',' in afterTextChanged().
But I could not manage to show a comma on the softkeyboard.
In android namespace you can use:
android:inputType="numberDecimal"
Which enables you to input the "."

Android numberDecimal, considering locale in xml layout

For e.g. an EditText it is normal to specify android:inputType="numberDecimal" for a text field supposed to contain a decimal number. But this assumes that '.' is used as the decimal separator and in some countries ',' is used instead. Is it possible to specify in xml that the users locale needs to be considered or do I have to do it manually in my code?
This is known bug, see here for more information.
A possible workaround is to set android:inputType="numberDecimal" (so the digit keyboard will be opend) and android:digits="0123456789.," (so the comma can be entered into the EditText). Then add a TextChangedListener and do something like Double.parseDouble(editable.toString().replace(',', '.')); in afterTextChanged.

Android virtual keyboard turn on caps lock

I have an edit text field. When the user clicks on it by default it shows small letters on the virtual keyboard.
I want by default to display first letter caps and rest of them small on the keyboard.
How can this be done?
android:capitalize is deprecated. So please use: android:inputType
android:inputType="textCapSentences"
Try adding android:capitalize="sentences" to the definition of the EditText in your Layout file. This should capitalize the first character of the sentence. If you want to begin each word with a capital letter use words.
More about this can be found in the API.
In order to captialize every character of EditText
use these property.
android:capitalize="characters"
I used below attribute with textCapCharacters value in my EditText to turn on caps lock on the virtual keypad and it worked.
android:inputType="textCapCharacters"
To capitalize all characters of Keyboard use this in your edittext in xml:
android:inputType="textCapCharacters"
To capitalize of the first character of every sentence use this :
android:inputType="textCapSentences"

Categories

Resources