我想在@
中写以TextView
符号开头的文本。但是,当我在两个地方都将其写为硬编码并使用字符串资源时,错误显示为missing /
。当我在@
之前键入一些字符时,它可以正常工作。但是,我想在一开始就写它。如何实现呢?
答案 0 :(得分:2)
在
之类的String.xml中添加Unicode字符<string name="character">\u0040 character</string>
将此添加到您的文本视图中,例如:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/character"/>
此处\ u0040表示'@'符号。
答案 1 :(得分:2)
像这样\@
<string name="character">\@ character</string>
或者您可以使用Unicode字符\0040
答案 2 :(得分:0)
按照错误提示只写“ \ @”;)(这是一个特殊字符,需要用“ \”转义)