Android 如何在文本视图中显示双引号(";)符号?

Android 如何在文本视图中显示双引号(";)符号?,android,Android,我试图在xml文件的文本视图中用双引号显示一些单词。但它不起作用。请帮帮我 <TextView style="@style/TextStyle" android:text="message "quote string 1" and "quote string 2" end message" android:id="@+id/lblAboutPara3" android:autoLink="web"/> 任何人都知道这个问题

我试图在xml文件的文本视图中用双引号显示一些单词。但它不起作用。请帮帮我

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


任何人都知道这个问题的解决方案………..

strings.xml
中,您可以简单地用反斜杠转义特殊字符(例如双引号):

"message \"quote string 1\" and \"quote string 2\" end message"
但是在视图xml(例如
layout.xml
)中,必须使用HTML字符实体(如
):


有关更多信息,请访问使用
转义字符
。要显示双引号,请使用
\“

您的代码将被删除

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

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


使用
符号解决此硬代码问题:)


如果字符串中有双引号,则必须将其转义为(\”。用单引号括住字符串不起作用

在strings.xml中

<string name="good_example">This is a \"good string\".</string>
这是一个“好字符串”。

来源

您可以在任何xml文件中使用Unicode

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

这里向下滚动到C/C++/Java源代码,使用单引号来包装消息,并且可以在字符串中使用任意多的双引号

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

它可以在strings.xml\”中工作,但不能在layout.xml中工作。这个答案是不正确的,因为OP特别询问“双引号,在xml文件中的文本视图中”不在strings.xml中。如果您想在布局文件中使用“符号”而不使用string.xml,那么这必须是正确的。您不能在
strings.xml
中使用这个事实是一个大问题。
TextView.setText(Html.fromHtml("&ldquo; " + "YOUR TEXT" + " &rdquo;"));
<string name="good_example">This is a \"good string\".</string>
android:text="message \u0022quote string 1\u0022 and \u0022quote string 2\u0022 end message"
android:text='message "quote string 1" and "quote string 2" end message'