How to display double quotes(") Symbol in a TextView?

Android

Android Problem Overview


I'm trying to display some words in double quotes, in Text view in in xml file. But its not working. Pls 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"/>    

Any one knows solution for this.............

Android Solutions


Solution 1 - Android

In the strings.xml, you can simply escape special characters (eg double quotes) with a backslash :

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

But in views xml (eg layout.xml), you have to use HTML character entities (like &quot;) :

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

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

Solution 2 - Android

Use &quot; symbol to solve this hardcode problem :)

android:text="message &quot;quote string 1&quot;" 

Solution 3 - Android

use escape characters. To display double quote use \"

Your code will be

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

Solution 4 - Android

Please try

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

Solution 5 - Android

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 there scroll down to C/C++/Java source code

Solution 6 - Android

TextView.setText(Html.fromHtml("&ldquo; " + "YOUR TEXT" + " &rdquo;"));

Solution 7 - Android

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

In strings.xml

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

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

Solution 8 - Android

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

Solution 9 - Android

Use single quotes to wrap the message and you can use as many double-quotes as you want inside the string.

android:text='message "quote string 1" and "quote string 2" end message'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVigneshView Question on Stackoverflow
Solution 1 - AndroidlouiscoquioView Answer on Stackoverflow
Solution 2 - AndroidRoger AlienView Answer on Stackoverflow
Solution 3 - AndroidSunil Kumar SahooView Answer on Stackoverflow
Solution 4 - AndroidNikhilView Answer on Stackoverflow
Solution 5 - AndroidDaniel FView Answer on Stackoverflow
Solution 6 - AndroidNikhil BoradView Answer on Stackoverflow
Solution 7 - AndroidSatheeshView Answer on Stackoverflow
Solution 8 - AndroidJignesh AnsodariyaView Answer on Stackoverflow
Solution 9 - AndroidVivekView Answer on Stackoverflow