How to display double quotes (") Character in TextView?

I am trying to display a few words in double quotes, in a textual representation in an xml file. But that does not work. Help me.

<TextView style="@style/TextStyle" android:text="message "quote string 1" and "quote string 2" end message" android:id="@+id/lblAboutPara3" android:autoLink="web"/> 

Does anyone know a solution for this .............

+65
android
Jun 21 2018-11-11T00:
source share
8 answers

In strings.xml you can simply escape special characters (e.g. double quotes) with a backslash:

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

But in xml views (e.g. layout.xml ) you need to use HTML character characters (e.g. &quot; ):

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

For more information, visit http://developer.android.com/guide/topics/resources/string-resource.html

+120
Jun 21 '11 at 7:00
source share
— -

Use the &quot; to solve this problem with hard code :)

 android:text="message &quot;quote string 1&quot;" 
+58
Feb 03
source share

use escape characters . To display the use of double quotation marks \"

Your code will be

 android:text="message \"quote string 1\" and "quote string 2\" end message" 
+10
Jun 21 '11 at 7:00
source share

Try

 <TextView style="@style/TextStyle" android:text='message \"quote string 1\" and \"quote string 2\" end message' android:id="@+id/lblAboutPara3" android:autoLink="web"/> 
+7
Jun 21 2018-11-11T00:
source share

You can use Unicode in any XML file.

 android:text="message \u0022quote string 1\u0022 and \u0022quote string 2\u0022 end message" 

http://www.fileformat.info/info/unicode/char/0022/index.htm scroll down to the source code C / C ++ / Java

+5
Jul 29 '16 at 1:18
source share
 <TextView style="@style/TextStyle" android:text='message "quote string 1" and "quote string 2" end message' android:id="@+id/lblAboutPara3" android:autoLink="web"/> 
+3
Jun 21 2018-11-11T00:
source share
 TextView.setText(Html.fromHtml("&ldquo; " + "YOUR TEXT" + " &rdquo;")); 
+3
Dec 17 '15 at 10:43
source share

If you have a double quote in your string, you should escape it (\ ") . Surrounding the string with single quotes does not work.

In the strings.xml file

 <string name="good_example">This is a \"good string\".</string> 

Source : http://developer.android.com/guide/topics/resources/string-resource.html

-2
Dec 19 '15 at 5:07
source share



All Articles