Example #1
0
        private void CreateAndSetHolder(ViewGroup parent, out View view, out ShopListAdapterViewHolder holder, int position)
        {
            holder = new ShopListAdapterViewHolder();
            var inflater = _context.GetSystemService(Context.LayoutInflaterService).JavaCast <LayoutInflater>();

            //replace with your item and your holder items
            //comment back in
            view = inflater.Inflate(Resource.Layout.shop_item_template, parent, false);

            holder.Name        = view.FindViewById <TextView>(Resource.Id.txtName);
            holder.Description = view.FindViewById <TextView>(Resource.Id.txtDescription);
            holder.Round       = view.FindViewById <TextView>(Resource.Id.txtRound);
            holder.Edit        = view.FindViewById <TextView>(Resource.Id.txtEdit);
            holder.Delete      = view.FindViewById <TextView>(Resource.Id.txtDelete);

            holder.Edit.Click   += (s, e) => { GoToEditActivity(position); };
            holder.Delete.Click += async(s, e) => { await DeleteProductFromList(position); };

            view.Tag = holder;
        }
Example #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;
            ShopListAdapterViewHolder holder = null;

            if (view != null)
            {
                holder = view.Tag as ShopListAdapterViewHolder;
            }

            if (holder == null)
            {
                CreateAndSetHolder(parent, out view, out holder, position);
            }

            var product = _shops[position];

            holder.Name.Text        = product.Name;
            holder.Description.Text = product.Description.ToString();
            holder.Round.Text       = product.Radius.ToString();

            return(view);
        }