Is it possible to access a string-array item in Android?

前端 未结 1 1854
[愿得一人]
[愿得一人] 2020-12-20 11:59

snip-code from values/string.xml:


    Today
    

        
相关标签:
1条回答
  • 2020-12-20 12:19

    See the selected answer here: Android - reference a string in a string array resource with xml.

    According to that answer, have to do something like this:

    <string name="earth">Earth</string>
    <string name="moon">Moon</string>
    
    <string-array name="system">
        <item>@string/earth</item>
        <item>@string/moon</item>
    </string-array>
    

    Then you would simply do:

      <Button ....
      android:text="@string/earth" />
    
    0 讨论(0)
提交回复
热议问题