Android XML转义符"@"象征 [英] Android XML escape "@" Symbol
问题描述
您如何将@
用作Android XML文件中的文本,因为它具有特殊含义?我有一个TextView
,它将仅包含文本@
How do you use the @
as text in an Android XML file, as it has special meaning? I have a TextView
which will simply hold the text @
我尝试过:
<TextView
android:id="@+id/at_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/account_name"
android:gravity="center_horizontal"
android:padding="3dip"
android:text="@" />
那当然不能解决错误
错误:错误:未指定资源类型(在文本"中,值为"@").
error: Error: No resource type specified (at 'text' with value '@').
因此,我尝试将其指向strings.xml
中的条目,如下所示:
<string name="at">@</string>
并显示错误:
So I tried pointing it to an entry in strings.xml
like this:
<string name="at">@</string>
and that shows the error:
错误:错误:未指定资源类型(在'at'处,值为'@').
error: Error: No resource type specified (at 'at' with value '@').
那么我如何将@
用作TextView的文本?
So how do I escape @
as the text for a TextView?
推荐答案
使用这种方式..............
use this way ..............
<string name="at">\@</string>
这篇关于Android XML转义符"@"象征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!