В Android я пытаюсь установить цвет из res/values/colors.xml
Использование title.setBackgroundColor()
В настоящее время я могу установить его с помощью: title.setBackgroundColor(Color.GREEN);
Однако я хотел бы сослаться на цвет из .xml
Когда я использую:
title.setBackgroundColor(R.color.white);
ссылаясь на:
<color name="white">#FFFFFF</color>
Студия Andriod сообщает:
Should pass resolved color instead of resource id here: `getResources().getColor(R.color.white)` less... (⌘F1)
This inspection looks at Android API calls that have been annotated with various support annotations (such as RequiresPermission or UiThread) and flags any calls that are not using the API correctly as specified by the annotations. Examples of errors flagged by this inspection:
Passing the wrong type of resource integer (such as R.string) to an API that expects a different type (such as R.dimen).
Forgetting to invoke the overridden method (via super) in methods that require it
Calling a method that requires a permission without having declared that permission in the manifest
Passing a resource color reference to a method which expects an RGB integer value.
...and many more. For more information, see the documentation at http://developer.android.com/tools/debugging/annotations.html
title.setBackgroundColor(ContextCompat.getColor(context, R.color.white));
- person Devil10   schedule 21.04.2018