我试图在双引号中显示一些单词,在xml文件的Text视图中.但它不起作用.请帮助我.
<TextView
style="@style/TextStyle"
android:text="message "quote string 1" and "quote string 2" end message"
android:id="@+id/lblAboutPara3"
android:autoLink="web"/>
Run Code Online (Sandbox Code Playgroud)
任何人都知道这个解决方案.............
lou*_*uio 172
在中strings.xml,您可以使用反斜杠简单地转义特殊字符(例如双引号):
"message \"quote string 1\" and \"quote string 2\" end message"
Run Code Online (Sandbox Code Playgroud)
但在视图xml(例如layout.xml)中,您必须使用HTML字符实体(如"):
"message "quote string 1" and "quote string 2" end message"
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请访问http://developer.android.com/guide/topics/resources/string-resource.html
Rog*_*ien 65
使用"符号来解决这个硬编码问题:)
android:text="message "quote string 1""
Run Code Online (Sandbox Code Playgroud)
Sun*_*hoo 14
用escape characters.显示双引号使用\"
你的代码将是
android:text="message \"quote string 1\" and "quote string 2\" end message"
Run Code Online (Sandbox Code Playgroud)
请试试
<TextView
style="@style/TextStyle"
android:text='message \"quote string 1\" and \"quote string 2\" end message'
android:id="@+id/lblAboutPara3"
android:autoLink="web"/>
Run Code Online (Sandbox Code Playgroud)
TextView.setText(Html.fromHtml("“ " + "YOUR TEXT" + " ”"));
Run Code Online (Sandbox Code Playgroud)
<TextView
style="@style/TextStyle"
android:text='message "quote string 1" and "quote string 2" end message'
android:id="@+id/lblAboutPara3"
android:autoLink="web"/>
Run Code Online (Sandbox Code Playgroud)
您可以在任何xml文件中使用Unicode
android:text="message \u0022quote string 1\u0022 and \u0022quote string 2\u0022 end message"
Run Code Online (Sandbox Code Playgroud)
http://www.fileformat.info/info/unicode/char/0022/index.htm那里向下滚动到C / C ++ / Java源代码
如果您的字符串中有双引号,则必须将其转义(\")。用单引号将字符串括起来是行不通的。
在strings.xml中
<string name="good_example">This is a \"good string\".</string>
Run Code Online (Sandbox Code Playgroud)
来源:http : //developer.android.com/guide/topics/resources/string-resource.html
| 归档时间: |
|
| 查看次数: |
84253 次 |
| 最近记录: |