android:将字体图标显示为数字字符串序列

标签 android font-awesome

我想放一个Font-Awesome textview 文本中的图标。设置文本后,android 会显示一个字符串序列而不是字体图标。

我的代码是:

String formatedSection = formatedSection + sections.get(i).getContent() +getResources().getString(R.string.icon_ref);

我在 string.xml 中定义 icon_ref 如下:

 <string name="icon_ref">&#xf075;</string>

我关注了these instructions添加字体图标。我做错了什么?

最佳答案

如果您在那个简短的指南中执行了第 5 步,您的问题似乎忘记了 Java 和 XML 之间存在差异。

In XML you use XML escape (&...;), in Java you'll probably have to use Java escape (\u...). – Biffen May 20 at 10:10

尝试将字符串硬编码为“\uf075”,它会非常有效。

关于android:将字体图标显示为数字字符串序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30829747/

相关文章:

Android Play Billing Library : onSkuDetailsResponse responseCode is 0, 但 skuDetailsList 的大小也是 0

android - 使用 android.os.FileObserver 观察 "\data"目录不工作

android - Paypal 仅在美国和英国以沙盒模式测试信用卡?

android - 你如何使用 Gradle 自定义 aar 包名称?

html - opencart 2.0.1.1 中缺少图标

css - 将 Font Awesome 图标排列在链接的电话号码/电子邮件的左侧

android - 使用 AppCompat v22.1.0 时如何在 super.onCreate 之前设置 ContentView?

html - 如何使用 CSS 增加 unicode 图标相对于其容器的 Font Awesome 的大小

javascript - 你如何在 nuxt 3 上获得很棒的字体设置

javascript - 使用 React 和 react-fa 在输入文本背景上动态放置一个 Font Awesome 图标