'Get List entry by clicking RecyclerView entry

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source