Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to type apostrophe character in android strings xml

Tags:

android

xml

If i try to do things like this, it doesn't work... (empty string or no resource type error)

<string name="make_sales_order">FAIRE L'ORDRE DE VENTE </string>

how to use apostrophe character in android string xml.any ideas?

like image 227
Lahiru Prasanna Avatar asked Sep 10 '16 09:09

Lahiru Prasanna


People also ask

How do you type an apostrophe on Android?

For Single Quote (') You can use \' in your string resources.

What is strings xml in Android?

String. xml file contains all the strings which will be used frequently in Android project. String. xml file present in the values folder which is sub folder of res folder in project structure.In Android Studio, we have many Views such as TextView,Button,EditText,CheckBox,RadioButton etc.


1 Answers

1. For Single Quote (')

You can use \' in your string resources.

or

You can can enclose the string in double quotes. For example:

"This'll work" will simply become This'll work once parsed

2. For double quote (")

"message \"quote string 1\" and \"quote string 2\" end message"

3. To represent in views xml (eg layout.xml), you have to use HTML character entities (like ")

"message &quot;quoted string 1&quot; and &quot;quoted string 2&quot; end message"

Though Android Studio in particular will complain about hardcoded strings and tell you to use a string resource in layout files instead of course!

like image 117
Dipali Shah Avatar answered Oct 13 '22 04:10

Dipali Shah