Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created August 27, 2021 05:29
Show Gist options
  • Save codeforfun-jp/343c7714b328e0e89dfd572f6f030d90 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/343c7714b328e0e89dfd572f6f030d90 to your computer and use it in GitHub Desktop.
Java - getColor method deprecated
TextView textView = findViewById(R.id.textView);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// API 23 以上
textView.setTextColor(getResources().getColor(R.color.black, getTheme()));
} else {
// API 23 未満
textView.setTextColor(getResources().getColor(R.color.white));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment