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

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 34,543 Points

Could Fun Facts be modified to also add images and have them change?

I know changing images is probably handled more deftly by something like Nav Drawer. But I modified the text part of Fun Facts to be related to Astronomy and I was wondering if I could design another class, structured as an analog to the ColorWheel class, and have different cool pictures of stars, planets and other astronomical objects.

If so, would the array of pictures be based on string like the Fact Book or Int/IntAsString like the ColorWheel class?

If this is ill-advised or will otherwise break the progam, would it be possible to add one stationary picture to the view that includes the stationary text "Did you know?"

If I do start messing around with this, I am going to save it in a zip file or apk before I start. I have written it twice - once as narrated by Ben J. and yesterday as narrated by Ben D.

I thought it might be fun to kick it up a notch.

Happy New Year everyone.

Nancy M.

2 Answers

Seth Kroger
Seth Kroger
56,407 Points

Yes, that's certainly possible to do. First you would need to put the images in res/drawable, preferably in res/drawable-*dpi scaled to each resolution. (The Interactive Story App course shows you how to work with images/drawables if you haven't taken it yet.) The array in this case would be an array of ints (ie, int[]) where each int is an R.drawable.yourimagename. Then you would pass the chosen int to setBackground() instead of setBackgroundColor().

Nancy Melucci
seal-mask
.a{fill-rule:evenodd;}techdegree
Nancy Melucci
Front End Web Development Techdegree Student 34,543 Points

Thank you. I did the Interactive Story App last summer but it developed a weird sync issue at the very end - so I may write it again. I will save my Fun Facts version and try out the images, but probably after I finish the Lists and Adapters course. Thanks for taking the time to answer my question. I look forward to experimenting with making Fun Facts even "funner".

Nancy