Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created August 27, 2021 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/184dadaf7bb798c88bfbb7dd31200107 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/184dadaf7bb798c88bfbb7dd31200107 to your computer and use it in GitHub Desktop.
Kotlin - getColor method deprecated
val textView = findViewById<TextView>(R.id.textView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// API 23 以上
textView.setTextColor(resources.getColor(R.color.black, theme))
} else {
// API 23 未満
textView.setTextColor(resources.getColor(R.color.white))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment