I tried
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" >
I realize it can accept any characters. So, what is special having android:inputType="textPersonName"
, compared to not having it?
The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.
A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing capabilities.
Android EditText Attributes It is used to change the color of the text. It is used to change the text color of hint text. It is used to specify the size of the text. It is used to change the style (bold, italic, bolditalic) of text.
The difference is that if you use "textPersonName", the user can not insert new lines (the enter button is not showed)
Spelling check is not done when using android:inputType="textPersonName"
but it is done in textCapWords
.
So if you use textPersonName
there won't be red underline for names but first letter of each name (firstname, middlename, lastname etc) won't be capitalized.
so best solution is combining both with an or
that is android:inputType="textPersonName|textCapWords"
.
now there won't be red underline for name and first letter would be capitalized also
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