android - 如何在包含特殊符号的字符串资源中保存条目

标签 android android-resources

在下面发布的 strings.xml 条目中,我想保存一个 url,它包含 & 符号。无法识别此符号...如何将链接保存为 strings.xml 中的条目...无法识别 & 符号

网址

    <string name="BASE_URL">https://en.wikipedia.org/w/api.php? 
    action=query&format=json&list=search&srsearch=Trump</string>

最佳答案

只需将每个 & 替换为 &

<string name="BASE_URL">https://en.wikipedia.org/w/api.php? 
    action=query&amp;format=json&amp;list=search&amp;srsearch=Trump</string>

还有一些其他字符可以替换:

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

关于android - 如何在包含特殊符号的字符串资源中保存条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56947867/

相关文章:

java - 为什么我的加速度传感器在关闭 Activity 后仍在工作?

android - 在 RecyclerView 中滚动时图像闪烁

php - 使用php脚本在Android应用程序中上传图像

android - 为什么 ColorStateList 的按下状态不能与 ListView 项目一起使用?

android - 使用应用程序 :menu in android's Toolbar I cannot locate the menu items 时

android - 使用 fragment 时如何管理应用栏?

android - Firebase runloop (3.0.0) 中的未捕获异常在我的生产 Android 应用程序中。请报告给 support@firebase.com

android - 在 Android Studio 中使用字符串资源翻译文本

android - 删除菜单图标和标题之间的空格

android - 关于 android 可绘制文件夹的说明