Recently, when using context.getResources().getColor(R.color.color1) or getResources().getColor(R.color.color1), the system prompts that this method is outdated.
After Android 6.0, the system provides
ContextCompat.getColor(context, R.color.color1) 方法来代替原来的getColor()方法
The source code of ContextCompat.getColor() is as follows:
Similarly, when using the getResources().getDrawable() method, you can also use the ContextCompat.getDrawable() method instead.
The source code of the ContextCompat.getDrawable() method is as follows. The system automatically adapts it for us. It is recommended to use