getResources().getColor() is deprecated
As we already know getResources().getColor() is deprecated since API level 23 from the official document
So what is the alternative of getColor()?
from API level 23, getColor is added in ContextCompat.
So just call
1 |
ContextCompat.getColor(context, R.color.color_id); |
from official document of ContextCompat.getColor()
Returns a color associated with a particular resource ID
Starting in
M
, the returned color will be styled for the specified Context’s theme.