【问题标题】:How to know if the strings.xml is the default file?如何知道 strings.xml 是否是默认文件?
【发布时间】:2022-01-05 01:59:46
【问题描述】:

我在这个项目中有 7 个字符串

strings.xml //This is the default
strings.xml (en)
strings.xml (ar)
strings.xml (es)
strings.xml (de)
strings.xml (it)
strings.xml (ru)

我在这样的服务器中有 JSON

[
  {
    "default": {
      "Message": "..."
    },
    "en": {
      "Message": "..."
    },
    "ar": {
      "Message": "..."
    },
    "es": {
      "Message": "..."
    },
    "de": {
      "Message": "..."
    },
    "it": {
      "Message": "..."
    },
    "ru": {
      "Message": "..."
    }
  }
]

我想根据设备语言读取消息,但问题是如何知道 strings.xml 是否是显示来自 JSON 的默认消息的默认文件?

【问题讨论】:

标签: android android-layout


【解决方案1】:

您可以使用this 方法。

总而言之,您在每个strings.xml 中声明一个string,说明当前正在使用哪个。

【讨论】:

    猜你喜欢
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    相关资源
    最近更新 更多