android - 在 TextView 的 Text 中转义 ""

标签 android

我有一个 textView,我将 s 字符串粘贴为文本,其中有一些“双引号字符”我如何转义这些字符。

最佳答案

反斜杠双引号在 XML 布局中不起作用。您应该使用 HTML 代码 (quot),如下所示:

<TextView android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:text="Here goes my &quot;escaped&quot; text!" />

上面的代码将显示一个包含以下内容的 TextView:

Here goes my "escaped" text!

XML 有 5 of these predifined entities :

&quot;   "
&amp;    &
&apos;   '
&lt;     <
&gt;     >

关于android - 在 TextView 的 Text 中转义 "",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7118221/

相关文章:

android - Android 中 ActionScript 3 的事件广播的等价物是什么?

java - TessBaseAPI 无法解析符号 tess-two OCR Android

android - ScrollView 在水平滑动行时垂直移动

android - 是否有像android这样的Rhodes本地存储有共享偏好

android - 重复的属性application @ appComponentFactory

android - 如何在 Jetpack Compose 中使小部件不可见?

Android Studio - 应用程序安装失败

android - 从新的照片应用程序中挑选图像

手机屏幕关闭时,Android AlarmManager 默认为 5 分钟

java.lang.NullPointerException - 注销时出错 Android