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 trialPhil White
Courses Plus Student 9,519 PointsStuck on android improving our code challenge...
Let's continue to add color to MealActivity. In the onCreate() method, set the text color of foodLabel to Color.BLUE and then set the text color of drinkLabel to Color.GRAY.
And this is the code you start with
7 Answers
Steve Hunter
57,712 PointsThe GRAY
needs to be capitalised.
Phil White
Courses Plus Student 9,519 PointsThank you it worked!
Nathan Fox
Courses Plus Student 850 PointsfoodLabel.setTextColor(Color.BLUE); drinkLabel.setTextColor(Color.Gray); That's what I put and it worked for me. I hope this helps.
Juan Gallardo
1,568 PointsThis is what worked for me.
public class MealActivity extends Activity {
public TextView foodLabel;
public TextView drinkLabel;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_meal);
foodLabel = (TextView) findViewById(R.id.foodTextView);
foodLabel.setTextColor(Color.BLUE);
drinkLabel = (TextView) findViewById(R.id.drinkTextView);
drinkLabel.setTextColor(Color.GRAY);
RelativeLayout mealLayout = (RelativeLayout) findViewById(R.id.mealLayout);
mealLayout.setBackgroundColor(Color.GREEN);
}
}
Steve Hunter
57,712 PointsWhat do you need, Juan?
Steve Hunter
57,712 PointsTry something like, foodLabel.text.setTextColor(R.Color.BLUE);
Autocomplete will probably assist you too.
Steve.
Phil White
Courses Plus Student 9,519 PointsNope that didn't work, Thanks for trying to help tho
Steve Hunter
57,712 PointsSecond attempt ... foodLabel.setTextColor(Color.BLUE);
Phil White
Courses Plus Student 9,519 PointsNope still not working...
Steve Hunter
57,712 PointsI'm opening Eclipse now and will see what I can figure out. What error are you getting?
Phil White
Courses Plus Student 9,519 Pointsit just says "There is a compiler error. Please click on preview to view your syntax errors!"
and then in preview it says
./MealActivity.java:16: cannot find symbol symbol : variable Gray location: class Color drinkLabel.setTextColor(Color.Gray); ^ 1 error
Tom Spencer
7,713 PointsI was using = instead of a dot apparently it should have been a two coffee day today.
foodLabel = setTexColor(Color.BLUE); (SNAFU) Oddly enough when I put this foodLabel.setTextColor(Color.BLUE); all is good
Phil White
Courses Plus Student 9,519 PointsPhil White
Courses Plus Student 9,519 Points