In this blog,
I have talked about what to use instead of a deprecated function of getColor.
getResources().getColor(R.color.color_name)
is deprecated in API level 23.
So, we can use getColor(int, Theme)
instead.
Or
you can use the ContextCompat.getColor() which is part of the Support V4 Library (so it will work for all the previous API).
1 |
ContextCompat.getColor(context, R.color.your_color); |
instead of
1 |
getResources().getColor(R.color.color_name) |
getColor method
1 |
int getColor (Context mContext, int id) |
Returns a color connected with a particular resource ID.