mercredi 3 juin 2020

Using ContextCompat.getColor in fragment Kotlin?

I have a check box in fragment and trying to set text color on it using ContextCompat.getColor

the code

optionCb.setTextColor(ContextCompat.getColor(activity,android.R.color.white));

It shows error

required : Context 
Found : fragmentactivity

Even used

optionCb.setTextColor(ContextCompat.getColor(activity.applicationContext,android.R.color.white));

Still shows error

What should be the context object here?




Aucun commentaire:

Enregistrer un commentaire