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 Dynamically Changing the Background Color

Trying to change background color I know I'm close. my code relativeLayout.setBackGroundColor(Color.GREEN);

just need a little help

MealActivity.java
import android.os.Bundle;
import android.widget.TextView;

public class MealActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_meal);

        TextView foodLabel = (TextView) findViewById(R.id.foodTextView);
        TextView drinkLabel = (TextView) findViewById(R.id.drinkTextView);
        RelativeLayout mealLayout = (RelativeLayout) findViewById(R.id.mealLayout);
        relativeLayout.setBackGroundColor(Color.GREEN);
    }
}

2 Answers

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Hi Mike,

You are indeed close. It should be:

mealLayout.setBackGroundColor(Color.GREEN);

In the previous line you called your RelativeLayout "mealLayout". So when you want to do stuff to that RelativeLayout, you refer to its name "mealLayout"

I hope this helps.

i tried that and it's still saying theirs a mistake, i don't know why.

Jon Kussmann
Jon Kussmann
Courses Plus Student 7,254 Points

I should have been a little more careful.

It is setBack*groundColor, not setBackG*roundColor.

yea i just figured out i was messing up on the caps, thanks for the help.