Пример #1
0
        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),
                    _boxedView);
                break;

            case ViewTypeFooter:
                viewHolder = new FooterViewHolder(
                    LayoutInflater.FromContext(_context).Inflate(Resource.Layout.FooterCell, parent, false),
                    _boxedView);
                break;

            default:
                viewHolder = new ContentViewHolder(
                    LayoutInflater.FromContext(_context).Inflate(Resource.Layout.ContentCell, parent, false));
                viewHolder.ItemView.SetOnClickListener(this);
                break;
            }
            _viewHolders.Add(viewHolder);
            return(viewHolder);
        }
Пример #2
0
        private 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;
            }

            holder.TextView.SetPadding(
                (int)view.Context.ToPixels(_boxedView.FooterPadding.Left),
                (int)view.Context.ToPixels(_boxedView.FooterPadding.Top),
                (int)view.Context.ToPixels(_boxedView.FooterPadding.Right),
                (int)view.Context.ToPixels(_boxedView.FooterPadding.Bottom));

            holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_boxedView.FooterFontSize);
            holder.TextView.SetBackgroundColor(_boxedView.FooterBackgroundColor.ToAndroid());
            if (_boxedView.FooterTextColor != Color.Default)
            {
                holder.TextView.SetTextColor(_boxedView.FooterTextColor.ToAndroid());
            }

            // Update text
            holder.TextView.Text = formsCell.Text;
        }