public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { // Inflate the item View cell = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.chat_button_cell, parent, false); // Create a ViewHolder to find and hold these view references, and register OnClick with the view holder: EventButtonViewHolder vh = new EventButtonViewHolder(cell, OnClick); return(vh); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { EventButtonViewHolder vh = holder as EventButtonViewHolder; Tuple <string, Color> buttonSettings = Constants.GetChatMessageButtonSettings(_context, EventButtons[position].Name, EventButtons[position].Icon); vh.Button.SetIconResource(GetIconResourceId(buttonSettings.Item1)); var states = new int[][] { new int[] { global::Android.Resource.Attribute.StateSelected }, new int[] { -global::Android.Resource.Attribute.StateSelected } }; ColorStateList backgroundCsl = new ColorStateList(states, new int[] { buttonSettings.Item2, _normalButtonBackgroundColor }); ColorStateList iconCsl = new ColorStateList(states, new int[] { _selectedIconColor, buttonSettings.Item2 }); vh.Button.BackgroundTint = backgroundCsl; vh.Button.IconTint = iconCsl; vh.Button.Selected = position == SelectedPosition; vh.Button.Tag = EventButtons[position].Name; vh.Label.Text = EventButtons[position].Name; }