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 Build a Simple Android App (2014) Improving Our Code Adding More Colors

Add Color

I am getting an error on the foodTextView and drinkTextView I am lost as to why though?

MealActivity.java
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

I'm sorry. I had to double check the challenge. Its asking to set the text color for those two TextViews not the background color.

Hello,

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.

I tried it both ways and it won't work......

What error messages are you getting?

When I use drinkLabel its a symbol error for (int)

I got it I was using setBackground instead of setTextColor.....

Yup.....Thanks, figured it out at the same time you did....