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

please assist. setting text colors of foodLabel and drinkLabel

please advise accordingly

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);
      RelativeLayout foodLayout = (RelativeLayout) findViewById(R.id.foodLabel);
      foodLabel .setBackgroundColor(Color.BLUE);
      //RelativeLayout drinkLayout = (RelativeLayout) findViewById(R.id.drinkLayout);
      //drinkLayout.setBackgroundColor(Color.GRAY);
    }
}

put comments on the statements l added and also the lines before the comments above it are also ones l put

2 Answers

HEY, you've one example done for you in the challenge which sets the backGroundColor, so you can take example from there and set the textcolor like this.

foodLabel.setTextColor(Color.BLUE);

and the second one, you just change the foodLabel and the .BLUE. hope it helps.

this is the BEST answer!...hehehe happy Coding indeed!!...such people mek the forum so exciting!

thank you very much Abdiazz..

i actually managed to do it.. i changed the the color also for the drinklabel text as follows:

drinkLabel.setTextColor(Color.GRAY);

Just as you have shown me.

thanks a lot!

you're welcome and plz accept the answer as Best Answer ;) happy coding Nhema.