Reputation: 55
I cannot type
<Button
android:id="@+id/del"
android:text="<"
android:textColor="#FFFFFF"/>
it gives an error
Error:(317) Error parsing XML: not well-formed (invalid token)
Upvotes: 3
Views: 665
Reputation: 885
Do it like this in the XML:
<Button
android:id="@+id/del"
android:text="<"
android:textColor="#FFFFFF"/>
Programmatically:
button.setText("<");
Upvotes: 3
Reputation: 1521
You have to escape your text, the xml has particularities regarding escape text check this link https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
So, in your case replace "<"
for "<"
" "
& &
' '
< <
> >
Upvotes: 3
Reputation: 2825
Use <
for <
, >
for >
and &
for &
.
Please create string in your value folder.
<string name="lessThanSymbol"><</string>
And use like this-
android:text="@string/lessThanSymbol"
Upvotes: 1
Reputation: 856
Try This Code.You just have to set the height & width. Just Copy and paste this code in your xml.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/del"
android:text="<"
android:textColor="#FFFFFF"/>
Upvotes: 0
Reputation: 2757
If you want set ">" character in XML file you can do by following ways
1) By using CDATA you can achieve this.
2) Dynamically you can set to button as follows
yourButton.setText("<");
or you can use
android:text="<"
Hope this will helps you.
Upvotes: 1