I need to create a Spinner
(or exposed dropdown menu) where the user can select a duration, in this case an amount of days. Something like
one day
two days
three days
Later on I want to translate this app, so I can't use the displayed text in my code, e.g. something like
if(item.equals("one day"))
will fail for other languages than english.
So I want to have a "display value" (what's shown to the user, like "one day") and a technical id/key, something like "1DAY". How can that be done with Android resource files?
I finally want something like this:
<!-- give a technical key 1DAY/2DAYS/3DAYS etc to the items -->
<!-- this is just a mockup - how could something like this be really done? -->
<string-array name="duration">
<item key="1DAY">@string/one_day</item>
<item key="2DAYS">@string/two_days</item>
<item key="3DAYS">@string/three_days</item>
<!-- and so on -->
</string-array>
<!-- these strings could be translated -->
<string name="one_day">one day</string>
<string name="two_days">two days</string>
<string name="three_days">three days</string>