Пример #1
0
        // Fill in the contents of the photo card (invoked by the layout manager):
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            try
            {
                MessageViewHolder vh = holder as MessageViewHolder;

                // Set the ImageView and TextView in this ViewHolder's CardView
                // from this position in the photo album:
                vh.Username.Text = this.chatMessages[position].Username;
                vh.Message.Text  = this.chatMessages[position].Message;

                vh.Layout.SetGravity(GravityFlags.Left);
                vh.Layout.Background = this.context.GetDrawable(Resource.Drawable.friendBubbleChat);

                if (vh.Username.Text == this.user)
                {
                    vh.Layout.Background = this.context.GetDrawable(Resource.Drawable.selfBubbleChat);
                    vh.Username.Gravity  = GravityFlags.Right;
                    vh.Message.Gravity   = GravityFlags.Right;
                    vh.Username.SetTextColor(Android.Graphics.Color.White);
                    vh.Message.SetTextColor(Android.Graphics.Color.White);
                }
            }
            catch { }
        }
Пример #2
0
        // Create a new photo CardView (invoked by the layout manager):
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            // Inflate the CardView for the photo:
            View itemView = LayoutInflater.From(parent.Context).
                            Inflate(Resource.Layout.MessageCardView, parent, false);

            // Create a ViewHolder to find and hold these view references, and
            // register OnClick with the view holder:
            MessageViewHolder vh = new MessageViewHolder(itemView, OnClick);

            return(vh);
        }