'How to call a function on a RecyclerView Item click [android]

I did an OnClickListenner on RecyclerView Item in the ViewHolder class Item = small card + big card like that

init {
            itemView.setOnClickListener {
                if (prod_cardL.visibility==View.GONE){
                prod_cardL.visibility= View.VISIBLE
                prod_cardS.visibility= View.GONE
                }
    }}

I want it so when the user clicks the item gets bigger. Or make it small if it's already big. I want to know how to do what I wrote between ()?



Sources

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

Source: Stack Overflow

Solution Source