0
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    int numAlpha = Integer.parseInt(intent.getStringExtra(MainActivity.alphaInteger));
    int numRed = Integer.parseInt(intent.getStringExtra(MainActivity.redInteger));
    int numGreen = Integer.parseInt(intent.getStringExtra(MainActivity.greenInteger));
    int numBlue = Integer.parseInt(intent.getStringExtra(MainActivity.blueInteger));
    TextView textView = new TextView(this);
    textView.setText(message);
    setContentView(textView);
    textView.setTextColor(Color.argb(numAlpha, numRed, numGreen, numBlue));
}

I have an app where user can set ARGB and then TextView should be set to what user has defined. However, the text doesn't show up at all. When I remove the textView.setTextColor line, it starts showing again. I tested numAlpha, numRed, numGreen and numBlue with Log.v and they output everything correctly. What's the problem?

Thanks in advance.

user3757605
  • 442
  • 1
  • 9
  • 20
  • are you sure message isn't empty? What are the values for a/r/g/b? – Blackbelt Mar 14 '15 at 10:18
  • Message is not empty, as I already wrote, it works just fine if I remove textView.setTextColor line. There's a lot of code which set it but are you sure you need it? I already tested them with Log.v and they are correct. – user3757605 Mar 14 '15 at 10:45
  • no I don't need it. What are the values of a r g b ? – Blackbelt Mar 14 '15 at 10:50
  • http://stackoverflow.com/questions/4602902/how-to-set-the-text-color-of-textview-in-code – Raghu Mar 14 '15 at 10:59
  • I found out that all values are set depending on what I wrote in Blue field. Maybe something is wrong with this: intent.putExtra(alphaInteger, Integer.toString(text_alpha)); intent.putExtra(redInteger, Integer.toString(text_red)); intent.putExtra(greenInteger, Integer.toString(text_green)); intent.putExtra(blueInteger, Integer.toString(text_blue)); – user3757605 Mar 14 '15 at 11:19

1 Answers1

0

What's your numAlpha? It can't be zero or to small, and the a,r,g,b range is 0-255. Try to use:

public static int rgb(int red, int green, int blue);
codezjx
  • 9,012
  • 5
  • 47
  • 57