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

I am working on an app using the FunFacts app as a template. How would I assign pictures to facts?

I have added an imagebook just like factbook and am using that to hold the images in an array so they can be called in the on click method so how would I take one of those images and set it up to appear when a certain fact does? I cant upload my work I have tried and t wouldn't let me.

1 Answer

Hi Dalton,

Are the images currently in your app in the Drawable folders?

If so, you can create a field in your ImageBook class that references an image and sets it as the resource for an ImageView.

ImageBook[] mImages = .....;

mImageBook = mImages[2];
mImageView.setImageResource(mImageBook.getImage());

I have images and they show up on the app but i want to set certain images to certain fact like "Cherokee village is a town in arkansas." I want to have a picture of the sign only show up with this fact.

Hi Jon & Dalton,

I'd like to do the exact same thing: Add a picture to appear with each fact in the FunFacts app. I'm not sure what you mean by Drawables folder or the imagebook class. Is there a good tutorial somewhere? Or has someone else already done this? Thank you.