2

I know this is a repost. I had to ask this question because I past question there is not a good solution or backdated answer. I comment there about my problem but no reply.

My question is simple. How can I get name value of string-array?

<string-array name="spinerArray">
    <item name="one">First</item>
    <item name="two">Second</item>
    <item name="three">Third</item>
    <item name="four">Fourth</item>
</string-array>

I can get First, Second, Third from above array. But I want one, two, three, fourth also.

There is two question on this.

getResourceEntryName for an array item

how to extract the name attribute from string array?

One accepted answer is

attributes.getValue("name");

But this is not working for me. Can anyone help me please.

Community
  • 1
  • 1
Xplosive
  • 713
  • 3
  • 13
  • 25
  • Why do you need the name? – user Apr 02 '14 at 18:46
  • 1
    I want to store some link and give them a title. I stored link as value and stored title in name. thats why i need name also. @Luksprog – Xplosive Apr 02 '14 at 18:51
  • 1
    The most simple solution would be to have two mirroring arrays, one holding the actual data and the other holding the names. You'll then just use the index to get the name or/and value. The common sense solution would be an xml layout in the `xml` folder that you parse at your own discretion(suitable if the list would be bigger and changed more frequently). – user Apr 02 '14 at 19:29
  • Mirror array creats hamper when you change an element. There is always a scope to mistake. @Luksprog – Xplosive Apr 02 '14 at 19:33

0 Answers0