简体   繁体   中英

android value with string array item in resources

So I have a string-array

<string-array name="string_array">
   <item>A</item>
   <item>B</item>
   <item>C</item>
</string-array>

and I would like to assign values to those strings such as

<string-array name="string_array">
   <item value="1">A</item>
   <item value="2">B</item>
   <item value="3">C</item>
</string-array>

is there any easy way to do this? I could just store it in an xml file and read it in at runtime but I thought somebody might have an easier way.

Thanks!

I doubt that the type of array you are looking for even exists. Arrays are to be accessed through index not key value pairs. For your purpose I think that only string tag is sufficient because you can access an item by its name just like you wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM