Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,