如何在启动时在android文本视图中编写"@"符号



我想在TextView中写@符号开头的文本。但是,当我在两个地方将其编写为硬编码并使用字符串资源时,错误显示missing /.当我在@之前键入一些字符时,它工作正常。但是,我想在开头写它。如何实现这一点?

像这样使用它@

<string name="character">@ character</string>

或者您可以使用 Unicode 字符040

在字符串中添加 Unicode 字符.xml喜欢

<string name="character">u0040 character</string>

在文本视图中添加以下内容,例如:

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/character"/>

这里 \u0040 表示 ' @ ' 符号。

只需按照错误显示的那样写"\@";)(这是一个特殊字符,需要使用"\"进行转义(

最新更新