-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorsAdapter.cs
More file actions
33 lines (26 loc) · 911 Bytes
/
ColorsAdapter.cs
File metadata and controls
33 lines (26 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace Colors
{
using Android.Support.V7.Widget;
using Android.Views;
public class ColorsAdapter : RecyclerView.Adapter
{
ColorsContainer _container;
public ColorsAdapter(ColorsContainer container)
{
_container = container;
}
public override int ItemCount => _container.Size;
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
var colorHolder = holder as ColorsViewHolder;
colorHolder.Bkg.SetBackgroundColor(_container[position].AndroidColor);
colorHolder.Title.Text = _container[position].Name;
colorHolder.Title.SetTextColor(_container[position].AndroidColor.Invert());
}
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.ColorView, parent, false);
return new ColorsViewHolder(itemView);
}
}
}