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

How to return a fun fact with a designated color using random?

I want to do 2 versions of my fun facts project.

  1. I want to return a random fact with a designated color. How do I put the fact and the color in an array?

  2. I want to return a random fact with a designated image(imageview). How do I put the fact and the image in an array?

Thanks:)

1 Answer

Hi Partha,

Could you define an array for your three variables ... ['fact', 'color', 'image'] then make an array of that array:

[1]['fact', 'color', 'image'] [2]['fact', 'color', 'image'] [3]['fact', 'color', 'image'] [4]['fact', 'color', 'image'] [5] ...

you get the idea.

Alternatively, look at hashmaps - they could help you too.

Steve.