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,427 Points

Here:

private String [] colors = {

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