public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { // throw new System.NotImplementedException(); //all the items which appear on the Itemi.axml View Itemi = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Itemi, parent, false); TextView txtName = Itemi.FindViewById <TextView>(Resource.Id.txtName); TextView txtSubject = Itemi.FindViewById <TextView>(Resource.Id.txtSubject); TextView txtMessage = Itemi.FindViewById <TextView>(Resource.Id.txtMessage); CheckBox mDeleteProduct = Itemi.FindViewById <CheckBox>(Resource.Id.btn_delete); CheckBox mEditProduct = Itemi.FindViewById <CheckBox>(Resource.Id.btn_edit); CheckBox mDeleteAllProduct = Itemi.FindViewById <CheckBox>(Resource.Id.btn_multipleDelete); //checkBoxul pentru stergere multipla-> pus in MyView // LinearLayout hiddenLayout=Itemi.FindViewById<LinearLayout>(Resource.Id.showMoreLayout); //mEditProduct.Click += MEditProduct_Click; //Tot ce apare pe un card-pe Itemi-trebuie sa fie aici MyView view = new MyView(Itemi, OnCellClick_ButtonDelete, OnCellClick_ButtonEdit) { mName = txtName, mSubject = txtSubject, mMessage = txtMessage, mDeleteProduct = mDeleteProduct, mEditProduct = mEditProduct, mDeleteAllProduct = mDeleteAllProduct }; view.Update(mDeleteProduct); view.Update2(mEditProduct); return(view); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { MyView myHolder = holder as MyView; myHolder.mName.Text = mProducts[position].Name; myHolder.mSubject.Text = mProducts[position].Cantity; myHolder.mMessage.Text = (mProducts[position].Id).ToString(); myHolder.product = mProducts[position]; //pentru stergere multipla-ca sa imi tina minte checkboxul care a fost selectat //trebuie folosit AdapterPosition ca sa imi ia pozitia buna a produsului selectat myHolder.mDeleteAllProduct.Checked = mProducts[myHolder.AdapterPosition].Checked; //la checkbox-ul selectat ii dau pozitia produsului din adapter if (!myHolder.mDeleteAllProduct.HasOnClickListeners) //daca nu este selectat checkbox-ul { myHolder.mDeleteAllProduct.Click += (sender, e) => //si se apasa pe checkBox { mProducts[myHolder.AdapterPosition].Checked = !mProducts[myHolder.AdapterPosition].Checked; }; } }