无法从int转换为Android.Graphics.Color

cas*_*las 3 android xamarin

在我的 Resources--> Values--> colors.xml

<color name="myview_background">#EDDDDD</color>
Run Code Online (Sandbox Code Playgroud)

我试图将该颜色分配如下:

 holder.ItemView.SetBackgroundColor(Resource.Color.myview_background);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误,我想知道我该怎么办?

无法从int转换为Android.Graphics.Color

Jas*_*son 6

试试这个:

holder.ItemView.SetBackgroundColor(_activity.Resources.GetColor(Resource.Color.mainview_background));
Run Code Online (Sandbox Code Playgroud)