Escape "@" on Android

I am looking for a way to escape the โ€œ@โ€ character at the beginning of a line in the strings.xml resource in Android. I keep getting compilation errors and the linker in Eclipse refuses to work :( Does anyone know how?

+6
android
source share
4 answers

The Android Documentation website says that double backslash is used to remove characters.

<string name = "twitter"> \\ @ mytwitter </string>

+3
source share

You must use the "\" before the "@". eg,

escaped\@ 

:-)

+2
source share

The space between the slash and the slash worked for me, thanks! <string name="first">1\ /4</string>

+1
source share

According to the Android Developer's Guide , you will have to avoid certain backslash characters \ or span the entire string with double quotation marks " " . Only if the line starts with @ , should it be escaped.

Backslash:
<string name="twitter">\@user</string>
<string name="email"> user@domain </string>

Double quotes:
<string name="twitter">"@user"</string>
<string name="email"> user@domain </string>

The other characters to be escaped are < > & ' " ?

+1
source share

All Articles