Difference between getResources (). GetColor (R.color.Black) and directly R.color.Black
have I noticed strange eclipse behavior?
I have a static variable:
public static colorID = R.color.Black;
Sometimes it is the same as R.color.Black:
if(colorID == R.color.Black)
//sometimes it works
sometimes i need to use
if(colorID == getResources().getColor(R.color.Black));
It's really annoying to find a bug by testing if your code is big ...
So, I want to know why this sometimes works, why not, and why the returned integer is sometimes different and sometimes not. They both link to R.color.Black in my custom file color.xml
in my folder values
. Why are they sometimes different?
+3
source to share