본문으로 바로가기

SetTextColor 시 주의점

category StudiesAndroid 3년 전

TextView 의 setTextColor 시 문제가 생겼다.

 

textView.setTextColor(R.color.YOURCOLOR)

위 처럼 바로 R.color.YourColor 로 setColor 를 할 수 없다.

다음과 같이 해야 한다.

 

textView.setTextColor(getResources().getColor(R.color.YOURCOLOR))
//
textView.setTextColor(Color.RED)