gpt4 book ai didi

Android XML 转义 "@"符号

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:54:43 26 4
gpt4 key购买 nike

您如何使用 @作为 Android XML 文件中的文本,因为它具有特殊含义?我有一个 TextView它将简单地保存文本 @

我试过:

<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>并显示错误:

error: Error: No resource type specified (at 'at' with value '@').

那么我该如何转义 @作为 TextView 的文本?

最佳答案

这样使用......

 <string name="at">\@</string>

关于Android XML 转义 "@"符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11169051/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com