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 trialBen Mair
8,728 PointsAdd Color
I am getting an error on the foodTextView and drinkTextView I am lost as to why though?
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);
foodTextView.setBackgroundColor(Color.BLUE);
drinkLabel = (TextView) findViewById(R.id.drinkTextView);
drinkTextView.setBackgroundColor(Color.GRAY);
RelativeLayout mealLayout = (RelativeLayout) findViewById(R.id.mealLayout);
mealLayout.setBackgroundColor(Color.GREEN);
}
}
6 Answers
James Simshaw
28,738 PointsI'm sorry. I had to double check the challenge. Its asking to set the text color for those two TextViews not the background color.
James Simshaw
28,738 PointsHello,
You're saving your TextViews as foodLabel and drinkLabel, yet calling the setBackgroundColor method on foodTextView and drinkTextView instead of the previously stored foodLabel and drinkLabel.
Ben Mair
8,728 PointsI tried it both ways and it won't work......
James Simshaw
28,738 PointsWhat error messages are you getting?
Ben Mair
8,728 PointsWhen I use drinkLabel its a symbol error for (int)
Ben Mair
8,728 PointsI got it I was using setBackground instead of setTextColor.....
Ben Mair
8,728 PointsYup.....Thanks, figured it out at the same time you did....