Add value from @string to my array.xml

前端 未结 3 1469
粉色の甜心
粉色の甜心 2021-01-14 18:36

I have my array.xml to fill preferences value.


    English
    German

        
相关标签:
3条回答
  • 2021-01-14 18:56

    You can just create string arrays in string.xml and other string.xml(ru) etc.

    See below code snippet :-

    string.xml

    <!-- Language array -->
    <string-array name="languages">
        <item>English</item>
        <item>Russian</item>
    </string-array>
    

    string.xml(ru)

    <!-- Language array -->
    <string-array name="languages">
        <item>английский</item>
        <item>русский</item>
    </string-array>
    
    0 讨论(0)
  • 2021-01-14 18:59

    Have you tried something like this:

    res/values/array.xml
    res/values-fr/array.xml
    res/values-ja/array.xml
    

    And so on...

    If your issue is that you want to substitute the <item> value dynamically, you might have to do this in code. Check out this post: dynamic parameters in strings

    0 讨论(0)
  • 2021-01-14 18:59

    do this...

    <string name="jan">January</string>
    <string name="fev">February</string>
    <string name="mar">March</string>
    
    <string-array name="year">
        <item name="jan">@string/jan</item>
        <item name="fev">@string/fev</item>
        <item name="mar">@string/mar</item>
    </string-array>
    
    0 讨论(0)
提交回复
热议问题