Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCihan Kaptan
2,819 PointsHow to get Android Resources to Main Activity
Resources res = getResources(); final String[] array = res.getStringArray(R.array.facts_array);
This codes is working at Eclipse but Android Studio is giving Error for getResources() method ?
Alexander Schott
8,318 Pointssame problem here, unresolved method. It can't find the getResources() method.
3 Answers
kriz bus
281 PointsCheck the import statement...
Connor Myers
21,089 PointsYou can chain them all together and get rid of the resources variable like this:
String[] array = getResources().getStringArray(R.array.facts_array);
Don't know if this is going to change anything but It will help your code to look a little cleaner :)
Cihan Kaptan
2,819 PointsThere isnt any problem about imports. Everything is same at two tools but Android Studio doesnt let use getResources() method
Leonardo Vidal
14,603 PointsLeonardo Vidal
14,603 Pointswhat is the error?