Issue
Is it possible to create an resource in XML where the name
attribute references to a String resource?
Let me show an example:
In my strings.xml I have:
<string name="some_string">I am a string</string>
Can I (in some way) use the String resource as a name for another resource? As in:
<integer name="@string/some_string">1</integer>
To clarify some things:
- I know you can reference the value of an resource to a reference:
<string name="another_string">@string/some_string</string>
- I already tried doing it without quotes:
<integer name=@string/some_string>1</integer>
Solution
I don't think this will ever work.
Also this would be a very bad idea, because the value of your String can change by translations to other languages. Following this the name (ID) of your integer would change by using your App in different countries. This could break your code by changing the Phones default language.
Answered By - Simulant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.