title: Java - Set Color by switch case function
body: <p>I want to set the color of the TextView by the function getColor(). I tried a lot of different ways but I can't get it working. My code doesn't compile.</p>
  
  <pre><code>import java.awt.*;
  import android.graphics.Color;
  
  public class test extends Activity {
  
  TextView text1 = (TextView) findViewById(R.id.text1);
  
  text1.setTextColor(getcolorss(1));
  
  public Color getColor(int x) {
     switch(x) {
         case 1: return Color.BLUE; 
         case 2: return Color.RED;
     } 
  }
  
  }
  </code></pre>
  
  <p>How would you do it?</p>