This does not work either, the returned ID is always 0. The items for
which I am trying to retrieve an ID are in res/values/array.xml and
defined as:
<string-array name="itemName">
<item> value1 @ value2 </item>
<item> value3 @ value3 </item>
</string-array>
The user would have selected from another string-array one of the
itemName, the code knows the itemName and I would like to insert it
into a getResources().getStringArray to retrieve more info on the
item.
I tried the following with different combination of packageName but
either crash or return id = 0
String packageName = "com.coname.appname:itemName";
int itemsid=getResources().getIdentifier( packageName, null, null);
The version below also returns 0.
int itemid1 = getIdentifier("R.array."+itemName[listaa_position],
"array", getPackageName());
Thanks for any pointers.
On Feb 28, 7:04 am, Mark Murphy <[email protected]> wrote:
> Alain wrote:
> > Mark,
>
> > I tried your suggestion with this code, but this throws an exception.
>
> > String varName = "R.array."+itemName[listaa_position];
> > int itemsid=getResources().getIdentifier(varName, null,
> > getPackageName());
> > items = getResources().getStringArray(itemsid);
>
> > The itemName[] are string-array struct in the res/values/arrays.xml
>
> Try getIdentifier(itemName[...], "array", getPackageName());
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android 2.0 Programming Books:http://commonsware.com/books
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en