void BindFooterView(FooterViewHolder holder, TextCell formsCell) { var view = holder.ItemView; //footer visible setting if (string.IsNullOrEmpty(formsCell.Text)) { //if text is empty, hidden (height 0) holder.TextView.Visibility = ViewStates.Gone; view.Visibility = ViewStates.Gone; } else { holder.TextView.Visibility = ViewStates.Visible; view.Visibility = ViewStates.Visible; } //textview setting holder.TextView.SetPadding( (int)view.Context.ToPixels(_settingsView.FooterPadding.Left), (int)view.Context.ToPixels(_settingsView.FooterPadding.Top), (int)view.Context.ToPixels(_settingsView.FooterPadding.Right), (int)view.Context.ToPixels(_settingsView.FooterPadding.Bottom) ); holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_settingsView.FooterFontSize); holder.TextView.SetBackgroundColor(_settingsView.FooterBackgroundColor.ToAndroid()); if (_settingsView.FooterTextColor != Xamarin.Forms.Color.Default) { holder.TextView.SetTextColor(_settingsView.FooterTextColor.ToAndroid()); } //update text holder.TextView.Text = formsCell.Text; }
/// <summary> /// Ons the create view holder. /// </summary> /// <returns>The create view holder.</returns> /// <param name="parent">Parent.</param> /// <param name="viewType">View type.</param> public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { ViewHolder viewHolder; var inflater = LayoutInflater.FromContext(_context); switch ((ViewType)viewType) { case ViewType.TextHeader: viewHolder = new HeaderViewHolder(inflater.Inflate(Resource.Layout.HeaderCell, parent, false)); break; case ViewType.TextFooter: viewHolder = new FooterViewHolder(inflater.Inflate(Resource.Layout.FooterCell, parent, false)); break; case ViewType.CustomHeader: var hContainer = new HeaderFooterContainer(_context); viewHolder = new CustomHeaderViewHolder(hContainer); break; case ViewType.CustomFooter: var fContainer = new HeaderFooterContainer(_context); viewHolder = new CustomFooterViewHolder(fContainer); break; default: viewHolder = new ContentBodyViewHolder(inflater.Inflate(Resource.Layout.ContentCell, parent, false)); viewHolder.ItemView.SetOnClickListener(this); viewHolder.ItemView.SetOnLongClickListener(this); break; } _viewHolders.Add(viewHolder); inflater.Dispose(); return(viewHolder); }
/// <summary> /// Ons the create view holder. /// </summary> /// <returns>The create view holder.</returns> /// <param name="parent">Parent.</param> /// <param name="viewType">View type.</param> public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { ViewHolder viewHolder; switch (viewType) { case ViewTypeHeader: viewHolder = new HeaderViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.HeaderCell, parent, false), _settingsView); break; case ViewTypeFooter: viewHolder = new FooterViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.FooterCell, parent, false), _settingsView); break; default: viewHolder = new ContentViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.ContentCell, parent, false)); viewHolder.ItemView.SetOnClickListener(this); break; } _viewHolders.Add(viewHolder); return(viewHolder); }