Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

failing to add colors

how to add field color

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
    public void onCreate(Bundle savedInstanceState) {   

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


1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points


private String [] colors = {

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