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

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.