I need to be able to put a "-" in the string inside my strings.xml
file.
My problem is that when I am putting my string which is "1261eba2-9d8c-11e1-93e3-40409e0f44a1"
, eclipse yells:
Multiple annotations found at this line: - Replace "-" with an "en dash" character (–, &;#8211;)
How can I fix this?
As already mentioned the correct way to have a space in an XML file is by using \u0020 which is the unicode character for a space.
The reference to entity "Drop" must end with the ';' delimiter. How can I write character & in the strings. xml? In android studio, you can simply press Alt+Enter and it will convert for you.
Element names cannot start with the letters xml (or XML, or Xml, etc) Element names can contain letters, digits, hyphens, underscores, and periods.
So, when you read the error message, your answer will be that you have to replace -
with –
. Then it should work fine =)
http://en.wikipedia.org/wiki/Dash
The other answers are OK for when you want to display the string to the user. The user can't really tell the difference between a "real" dash and the unicode trickery.
But, if you really must have the dash (e.g. because that string is used as a password somewhere, or as a url key for an API) then you can just use this format:
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes"> <string name="EVA_API_KEY">3c42b725-5e20-41c8-982f-dee40be8a05b</string> </resources>
The warning will be removed and the string can be read using the regular:
getResources().getString(R.string.EVA_API_KEY);
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