Search code examples
androidviewtextcolor

Android view set text color


I am trying to dynamically change the font and background color of my app but when I try to set it just turns gray no matter what color I choose. I have verified the color is correct. any ideas.

mTitleText is a EditText

mTitleText = (EditText) findViewById(R.id.note_edit_title);
mTitleText.setTextColor(R.color.defaulttextred);

Solution

  • Just use

    mTitleText.setTextColor(getResources().getColorStateList(R.color.defaulttextred));