Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I write character ' in Android's strings.xml?

Tags:

android

How do I represent the single-quote character (') in strings.xml?

like image 620
NikhilReddy Avatar asked Oct 10 '11 14:10

NikhilReddy


People also ask

How do you add an apostrophe in string XML?

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

How do you write and in string?

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.

What is a text string in XML?

Note: A string is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). So, you can combine string resources with other simple resources in the one XML file, under one <resources> element. file location: res/values/filename.xml.

Why do we use string 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.


2 Answers

From the Documentation:

<string name="good_example">"This'll work"</string>
<string name="good_example_2">This\'ll also work</string>
like image 77
Felix Avatar answered Oct 04 '22 06:10

Felix


You want to display "This'll work", You should be replace &#8217; instead of '. The following code as:

<string name="good_example">"This&#8217ll work"</string>

like image 21
Hai Rom Avatar answered Oct 04 '22 07:10

Hai Rom