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

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 35,157 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,413 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
PLUS
Nancy Melucci
Courses Plus Student 35,157 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