Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void BindHeaderView(HeaderViewHolder holder, TextCell formsCell)
        {
            var view = holder.ItemView;

            // Judging cell height
            int cellHeight       = (int)_context.ToPixels(44);
            var individualHeight = formsCell.Height;

            if (individualHeight > 0d)
            {
                cellHeight = (int)_context.ToPixels(individualHeight);
            }
            else if (_boxedView.HeaderHeight > -1)
            {
                cellHeight = (int)_context.ToPixels(_boxedView.HeaderHeight);
            }

            view.SetMinimumHeight(cellHeight);
            view.LayoutParameters.Height = cellHeight;

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

            holder.TextView.Gravity       = _boxedView.HeaderTextVerticalAlign.ToAndroidVertical() | GravityFlags.Left;
            holder.TextView.TextAlignment = Android.Views.TextAlignment.Gravity;
            holder.TextView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_boxedView.HeaderFontSize);
            holder.TextView.SetBackgroundColor(_boxedView.HeaderBackgroundColor.ToAndroid());
            holder.TextView.SetMaxLines(1);
            holder.TextView.SetMinLines(1);
            holder.TextView.SetTypeface(null, Android.Graphics.TypefaceStyle.Bold);
            holder.TextView.Ellipsize = TextUtils.TruncateAt.End;

            if (_boxedView.HeaderTextColor != Color.Default)
            {
                holder.TextView.SetTextColor(_boxedView.HeaderTextColor.ToAndroid());
            }

            // Border setting
            if (_boxedView.ShowSectionTopBottomBorder)
            {
                holder.Border.SetBackgroundColor(_boxedView.SeparatorColor.ToAndroid());
            }
            else
            {
                holder.Border.SetBackgroundColor(Android.Graphics.Color.Transparent);
            }

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