tags:

views:

51

answers:

1

Hi all

I have a resources file called string.xml in res/valus directory

the file has many string resources

how can I obtain these items in an array from code ?

I tried

Field[] x=R.string.class.getFields();

but it does not work.

thanks

A: 

It works fine for me. You might detail your problem a little more though - what doesn't work? Note that the R.string class contains ints, not strings. Are you expecting strings? If you want a string from that resourceId int, call Context.getString(resourceId).

JRL
Thanks I'll try again and tell you the result
Mina Samy
Alright my problem was I used to display the length of the array like this txt.setText(x.length); it didn't throw a compile error but threw a runtime error but when wrote it like this txt.setText(String.valueOf(x.length)); it worked just fine.silly mistake indeed :)
Mina Samy