Android Build a Simple Android App with Java Improving Our Code Adding Colors

Why is this producing a compiler error?

I am pretty sure this should work. What will it take to get the compiler to recognize the dot operator symbol (if I understand the compiler error log correctly...)?

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);
        drinkLabel.setbackgroundColor(Color.GRAY);
    }
}

This portion is my contribution to the challenge:

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);
        //********************************************
        // MY PART:
        //********************************************
        foodLabel.setBackgroundColor(Color.BLUE); // My code
        drinkLabel.setbackgroundColor(Color.GRAY); // My code
    }
}

Never mind. I was mindlessly writing setBackgroundColor when I needed to write setTextColor. Problem existed between chair and keyboard.

1 Answer