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 with Java Improving Our Code Adding Colors

failing to add colors

how to add field color

MealActivity.java
public class MealActivity extends Activity {
  private ColorWheel colorWheel = new ColorWheel();

    public TextView foodLabel;
    public TextView drinkLabel;
  public class ColorWheel{
    //Fields or Member Vriables - propertiesabout the object
    private String [] colors = {
    "#39add1", // light blue
    "#3079ab", // dark blue
    "#c25975", // mauve
    "#e15258", // red
    "#f9845b", // orange
    "#838cc7", // lavender
    "#7d669e", // purple
    "#53bbb4", // aqua
    "#51b46d", // green
    "#e0ab18", // mustard
    "#637a91", // dark gray
    "#f092b0", // pink
    "#b7c0c7"  // light gray
};
  }
    @Override
    public void onCreate(Bundle savedInstanceState) {   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_meal);

        int color = colorWheel.getColor();
        foodLabel = (TextView) findViewById(R.id.foodTextView);
        drinkLabel = (TextView) findViewById(R.id.drinkTextView);
        RelativeLayout mealLayout = (RelativeLayout) findViewById(R.id.mealLayout);
        mealLayout.setBackgroundColor(Color.GREEN);


    }
};
 showFactButton.setTextColor(color);

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Here:

private String [] colors = {

Try removing the space between String and [] - it should be String[].