'How do I access a color programmatically in Kotlin

I tired using ContextCompact but I'm having 'unresolved reference'

 val changeColour = ContextCompat.getColor(closestView.context, R.color.white.color
)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source