Java - Set Color by switch case function
Posted
by user369150
on Stack Overflow
See other posts from Stack Overflow
or by user369150
Published on 2010-06-17T09:24:17Z
Indexed on
2010/06/17
9:33 UTC
Read the original article
Hit count: 164
I want to set the color of the TextView by the function getcolorss. I tried a lot of different ways but i cant get in it. Please help me i think the solution is easy.
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 getcolorss(int x)
{
switch(x)
{
case 1: return Color.BLUE;
case 2: return Color.RED;
}
}
}
© Stack Overflow or respective owner