2

My android app has an EditText field for email where user can give input.

But I'm trying to limit the options for that EditText so the user can just enter the allowed characters as email address. So this is my code

<EditText
    android:id="@+id/sign_up_password_edit_text"
    style="@style/SignUpEditTextStyle"
    android:hint="@string/password"
    android:inputType="textPassword"
    android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 !#$%&amp;'*+-/=?^_`{|}~ (),:;@[\]<>"
   />

but when trying to compile and run the project I'm getting this error:

Error:Execution failed for task ':app:mergeDebugResources'.

Error: The value of attribute "android:digits" associated with an element type "EditText" must not contain the '<' character

How can I fix that and include the '<' character?

Abdulmalek Dery
  • 996
  • 2
  • 15
  • 39
  • 2
    [This](https://stackoverflow.com/questions/3053062/how-can-i-write-character-in-android-strings-xml) will help . – ADM Mar 25 '18 at 07:37

4 Answers4

9

You need to encode it like web urls.

In your case: use &lt; for '<', &gt; for '>'. For more info, take a look at this.

Samir Alakbarov
  • 1,120
  • 11
  • 21
nhoxbypass
  • 9,695
  • 11
  • 48
  • 71
2

See xml special characters documentation here.

Sir Codesalot
  • 7,045
  • 2
  • 50
  • 56
2

escape char on XML,

"   &quot;
'   &apos;
<   &lt;
>   &gt;
&   &amp;
1

When you use wizards to customize any string in your XML file, you can use the following special symbols:

Symbol (name) Escape Sequence

< (less-than) ********* &#60; or &lt;

> (greater-than) ********* &#62; or &gt;

& (ampersand) ********* &#38;

' (apostrophe or single quote) ********* &#39;

" (double-quote) ********* &#34;

Khaled Mahmoud
  • 285
  • 2
  • 7