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 trialBrandon Wash
Courses Plus Student 1,186 PointsThe code below has a RelativeLayout variable named mealLayout. Change the background color of this layout to green. Use
I dont know where I messed up on this code. Any advice will be helpf guys. Thanks
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);
}
}
1 Answer
Ken Alger
Treehouse TeacherBrandon;
Welcome to Treehouse!
A couple of issues I see. Let's take a look at the challenge.
Task 1
The code below has a RelativeLayout
variable named mealLayout
. Change the background color of this layout to green. Use the constant Color.GREEN
as the parameter for the method you'll use.
First, in your code you want to be changing mealLayout
, not relativeLayout
as you have it. In the video and many of the projects, Ben Jakuben does name the variables the same as the type of variable, i.e. RelativeLayout relativeLayout
, but this challenge is different and doesn't necessarily mater. You could call it RelativeLayout brandonWash
it just isn't necessarily a meaningful name.
Secondly, the color name should be in all caps, so your code should look like:
mealLayout.setBackgroundColor(Color.GREEN);
Hope it helps and post back if you have other questions or are still stuck.
Ken
Brandon Wash
Courses Plus Student 1,186 PointsBrandon Wash
Courses Plus Student 1,186 PointsThanks Ken. I appreciate your feedback.