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 trial

Android

Location of the facts array and follow-up

Hi,

Out of curiosity, would it not be better to create the facts array out of the OnClickListener? Maybe even in another file?

Also, letโ€™s say I want to reference strings that are in a separate file (for ease of edition), with the facts array getting the facts in that file, would that be possible?

Cheers,

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Hey Rafael! You could create the facts array outside the OnClickListener or in another file, but ultimately as long as it makes sense to you, it doesn't matter too much where you put it. Also, you can use static variables to make something accessible outside of the file it's in. Hope that helps!

Thanks for the answer! In fact part of my question was answered in the following video, I jumped the gun on that topic :D

Best,