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
John Bergandino
8,455 PointsColor Complimenter Extra Credit for Android App Dev
I'm trying to complete the Color Complimenter extra credit at the end of the "Build an Interactive Story App" but I'm having trouble getting past the initial programming. The challenge states:
Write an app that asks the user for their favorite color, then take them to a new Activity that uses that color as a background color and says something nice about them.
I understand how to properly link the button/EditText to the program using findViewByID and setting up an onClickListener that sends the data to a new activity via an intent but I'm stuck at this point. I'm assuming I need to build an array containing several colors (and also insert an "if NULL fail-safe in the event the user inputs a color not in the array). I don't understand exactly how to build the array and sync that properly into the program...I've been rewatching the videos to try and create this app but I can't figure out how to get this working...I'm most likely over complicating my approach. Any help would be appreciated, thanks.
1 Answer
Daniel Hartin
18,106 PointsHi John
My approach would be to create a list view with a limited number of colours to avoid colours you haven't programmed for and perhaps a random colour option
Then create the intent adding the result of the list selection to the intent.
You could then set the new activity to use this string value to assign the background colour.
You could set a random number variable to an rgb value to randomly choose a colour as well.
Sorry I can't be of more help but once you get some code post back here if you get stuck and I will try to point you in the right direction
Thanks Daniel