0

So I have a bunch of entries in my RV. One entry is one Product. Those products are in a list of products. All of them have a barcode and a name:

List<Product>;

Product(barcode, name);

Now when I click on one of these entrys, I want to delete it. Therefore I have a function like this in class RecycleViewAdapter:

holder.parentLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            
            BackendClient.getInstance().deleteProduct(this.product);

        }

    });

Now how do I get the product of the entry I clicked in my RecycleViewAdapter class?

edin
  • 1
  • 3
  • ```Now how do I get the product of the entry I clicked in my RecycleViewAdapter class?``` Please elaborate this part. – Sujal Kumar Feb 26 '22 at 14:15
  • 1
    @SujalKumar Every entry in my RV is another product in my list. To delete it, I need the list entry (=product) of the entry I clicked on. – edin Feb 26 '22 at 14:22
  • I think this should help: https://stackoverflow.com/a/28304517/9520315 – Sujal Kumar Feb 26 '22 at 14:31
  • Using this way you could get the position of the entry clicked and then can further get the required ```Product``` object. – Sujal Kumar Feb 26 '22 at 14:33

0 Answers0