Cannot set button text to "<<<"
Asked Answered
R

3

4

I'm trying to set the text of a button to "<<<" from my xml but I get an "Error:(20) Error parsing XML: not well-formed (invalid token)"

    <Button
        android:id="@+id/test"
        android:text="<<<"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

So I jumped over to my strings.xml to enter it in there and that clearly won't work.

<string name="abc"> <<< </string>

Is there a workaround for this?

Recaption answered 17/5, 2018 at 17:26 Comment(0)
C
7

These are html entities, works in android studio as well:

> can be replaced with &gt;
< can be replaced with &lt;
" can be replaced with &quot;, &ldquo; or &rdquo;
' can be replaced with &apos;, &lsquo; or &rsquo;
} can be replaced with &#125;
& can be replaced with &amp;
space can be replaced with &#160;
Cholecalciferol answered 17/5, 2018 at 17:27 Comment(0)
V
3

Use &gt; for >, &lt; for < , &amp; for & ,&apos; for ' , &quot; for "

Valora answered 17/5, 2018 at 17:29 Comment(0)
H
3

You can use

< (less-than)                     &#60; or &lt;
> (greater-than)                  &#62; or &gt;
& (ampersand)                     &#38; or &amp;
' (apostrophe or single quote)    &#39; or &apos;
" (double-quote)                  &#34; or &quot;

please check out these links :

Predefined entities in XML

Using Special Characters in XML

Stackoverflow - escaping special characters like & in android xml

Horsefly answered 17/5, 2018 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.