Android: How to Set Color of Text Using a String
<p>I have an intent that brings two strings. 1 is the string for the message and the other is a string for the color.</p>

<p>The code below shows that the 2 strings are received. The "message" string is displayed in the textview which works correctly. However I need the string "messagecolor" to set the color of the textview. </p>

<p>I have a colors.xml file where the colors blue, green and red are defined.</p>

<p>So if the string "messagecolor" is blue to text will be blue. The same for red and green. If the string "messagecolor is not blue,red or green then the text will just appear black.</p>

<p>If someone could help me solve this it would be most appreciated.</p>

<p>Thank you </p>

<pre><code>// Get the message from the intent
    Bundle bundle = getIntent().getExtras();
    String messagecolor = bundle.getString(MainActivity.EXTRA_MESSAGE_COLOR);
    String message = bundle.getString(MainActivity.EXTRA_MESSAGE);


    // Create the text view
    TextView textView = new TextView(this);
    textView.setTextColor(getResources().getColor(R.color.blue));
    textView.setTextSize(100);
    textView.setText(message);
</code></pre>
