How to put a "-" file in a string.xml file

I need to be able to put a β€œ-” in a line inside my strings.xml file.

My problem is that when I put my line, which is "1261eba2-9d8c-11e1-93e3-40409e0f44a1" , eclipse yells:

A few annotations found on this line: - Replace the "-" with "en dash" (-, & amp ;; # 8211;)

How can i fix this?

+73
android string
May 14 '12 at 6:46 am
source share
7 answers

So, when you read the error message, your answer will be: you should replace - with – . Then it should work fine =)

http://en.wikipedia.org/wiki/Dash

+108
May 14 '12 at 6:51
source share

Other answers are fine if you want to display the string to the user. The user cannot tell the difference between a β€œreal” dash and a Unicode trick.
But if you really need to have a dash (for example, because this line is used as the password somewhere or as the url key for the API), you can simply 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 line can be read using regular:

 getResources().getString(R.string.EVA_API_KEY); 
+77
Jun 05 '12 at 10:18
source share

Use a backslash (\) before each special character. like me \ & android.

This is called an escape character. (\)

+14
May 14 '12 at 6:51
source share

A dash is a punctuation mark that looks like a hyphen or minus sign, but differs from both of these characters mainly in length and function. The most common versions of dashes are en dash (-) and em dash (-), named for the length of the font n of the upper stanza and upper case M, respectively.

Link

Just replace - with – because when you enter a dash on the keyboard, XML reads the dash as a minus, that's all.

+3
Dec 29 '15 at 12:11
source share

You probably have the following:

 <string name="test1">1261eba2-9d8c-11e1-93e3-40409e0f44a1</string> 

But you need either one of them:

 <string name="test2">1261eba2&#8211;9d8c&#8211;11e1&#8211;93e3&#8211;40409e0f44a1</string> <string name="test3">1261eba2–9d8c–11e1–93e3–40409e0f44a1</string> 

In the second, it is replaced by a. It is difficult to distinguish visually.

+1
May 14 '12 at 7:44
source share

To use a hyphen (& # 45) (-) ...

 <string name="abc">Welcome &#45; Bro...</string> 

and for more symbolic use below the link

http://www.degraeve.com/reference/specialcharacters.php

Enjoy ...

+1
Nov 05 '14 at 12:12
source share

The hot fix key combination in Eclipse is Ctrl + 1 by default, and Alt + Enter by default in Android Studio.

0
Dec 17 '18 at 15:58
source share



All Articles