【问题标题】:String Array Custom Property字符串数组自定义属性
【发布时间】:2014-01-08 09:33:09
【问题描述】:

我在 array.xml 中有一个字符串数组:

<string-array name="stringList">
    <item indent="true">Item1</item>
    <item indent="false">Item2</item>
    <item indent="false">Item3</item>
    <item indent="true">Item4</item>
</string-array>

正如您所注意到的,我需要为字符串(缩进)声明一个自定义属性。我的目标是生成一个带有 key = "ItemX" 和 value = "true/false" 的 HashMap。在android中可以这样做吗?有什么更聪明的方法吗?非常感谢。

【问题讨论】:

  • 为什么第 2 到 4 项的布尔值后面有双“”?

标签: android android-xml android-resources


【解决方案1】:

只需使用 2 个数组 :)

<string-array name="keys">
    <item>Item1</item>
    <item>Item2</item>
    <item>Item3</item>
    <item>Item4</item>
</string-array>

<string-array name="values">
    <item>true</item>
    <item>true</item>
    <item>false</item>
    <item>false</item>
</string-array>

【讨论】:

猜你喜欢
  • 2015-01-19
  • 2020-02-17
  • 2020-07-20
  • 1970-01-01
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 2019-05-08
  • 2016-06-29
相关资源
最近更新 更多