[ACCEPTED]-Get an integer array from an xml resource in Android program-android
Accepted answer
You need to use Resources to get the int 9 array; however you're using the system resources, which 8 only includes the standard Android resources 7 (e.g., those accessible via android.R.array.*
). To get your 6 own resources, you need to access the Resources 5 via one of your Contexts.
For example, all 4 Activities are Contexts, so in an Activity 3 you can do this:
Resources r = getResources();
int[] bases = r.getIntArray(R.array.UserBases);
This is why it's often useful 2 to pass around Context; you'll need it to 1 get a hold of your application's Resources.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.