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

getting error?

question is , 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.?

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);
        drinkLabel = (TextView) findViewById(R.id.drinkTextView);
        RelativeLayout mealLayout = (RelativeLayout) findViewById(R.id.mealLayout);
        mealLayout.setBackgroundColor(Color.GREEN);
         foodLabel.setBackgroundColor(Color.BLUE);
         drinlLabel.setBackgroundColor(Color.GREY); 
    }
}

2 Answers

Harry James
Harry James
14,780 Points

Hey Vishnu!

Looks like you've got a typo here:

drinlLabel.setBackgroundColor(Color.GREY); 
    ^

which should be:

drinkLabel.setBackgroundColor(Color.GREY); 

Hope it helps and, if you have any more problems, give me a shout :)

solve this problem but get error like....... ./MealActivity.java:15: error: cannot find symbol foodLabel.setBackgroundColor(Color.BLUE); ^ symbol: method setBackgroundColor(int) location: variable foodLabel of type TextView ./MealActivity.java:16: error: cannot find symbol drinklLabel.setBackgroundColor(Color.GREY); ^ symbol: variable GREY location: class Color ./MealActivity.java:16: error: cannot find symbol drinklLabel.setBackgroundColor(Color.GREY); ^ symbol: variable drinklLabel location: class MealActivity 3 errors

Harry James
Harry James
14,780 Points

Hey again Vishnu!

I've noticed that you're setting the background color rather than the text color.

Once you use the right method, the code should pass.

If you have any problems finding what method to use, give me a shout and I'll give you a hint :)

can use this code for textcolor....... foodLabel.setTextColor(Color.BLUE); drinklLabel.setTextColor(Color.GREY);

Harry James
Harry James
14,780 Points

Yep! That's correct.

But make sure you fix drinkLabel (You've got two l's, one lower-case and one uppercase)!

thanks harry.......got the answer!