Currently,, I am designing shopping cart...I had used recycler view to all display items,,, and also I had add to cart button in Recycler view ,,,whenever user clicks that add to cart button then I want to increment the count of total item (total count button is present outside the Recycler view in the fragment ) How can I send count value(Added to cart value) from Recycler view to that fragment....please help me . I am new to android
class Myadapter: RecyclerView.Adapter<Myadapter.MyViewHolder>() {
var items=ArrayList<Data>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder(LayoutInflater.from(parent.context).
inflate(R.layout.new_resource,parent,false))
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
var image=view.image
var Addtocart=view.Addtocart
Addtocart.setOnClickListener{
count++
}
}
override fun getItemCount(): Int {
return items.size
}
fun setListData(data:ArrayList<Data>){
this.items=data
}