8

I need two navigation buttons with their texts are < and >. However, the compiler doesn't allow me use those symbols, even if I use \< and \>.

Is there anyway to put these symbol into the XML design file?

Maveňツ
  • 1
  • 12
  • 50
  • 89
Luke Vo
  • 17,859
  • 21
  • 105
  • 181

4 Answers4

36

Use &lt; for <
Use &gt; for >
Use &amp; for &.

etc.

Nanne
  • 64,065
  • 16
  • 119
  • 163
  • Thanks, can you give me the complete list for all symbols please? Google doesn't work well with symbols. – Luke Vo May 25 '11 at 13:32
  • 3
    Check these: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references – Nanne May 25 '11 at 13:34
  • 1
    See [this page](http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php). – Gabriel Negut May 25 '11 at 13:34
  • hei nanne,how can i use this?suppose i need to desplay a text including Cuisine: Thai,Chinese & Vietnamese.but here this "&"" can not use here rather i have to use "and".how can i use "&" inside a text line???? – Android Girl Apr 12 '12 at 10:59
  • If you need an '&' you use `&`, just like the answer says. – Nanne Apr 12 '12 at 11:24
4

Use &#60; for <

Use &#62; for >

Use &#38; for &

use &#34; for "

for complete List of symbol

use &# decimal code of the symbol ; as above

Enjoy Programming..

AMD
  • 1,662
  • 18
  • 39
2

It is encouraged for Android programmers to store String values in res/values/strings. If you add a String here, you can reference it in your xml file like so: android:text="@string/mystring"

Phil
  • 35,852
  • 23
  • 123
  • 164
1

Declare this in string.xml and use:

<string name="sna">Synonyms &amp; Antonyms</string>

And simply call this in:

<TextView 
    android:text="@string/s_n_a"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/White"
    android:layout_gravity="center"
    android:textAppearance="?android:attr/textAppearanceLarge"/>

Use &lt; for <

Use &gt; for >

Community
  • 1
  • 1
Maveňツ
  • 1
  • 12
  • 50
  • 89