title: RecyclerView Effect Selected items in Android Kotlin
body: <p>Programming Language : KOTLIN</p>
  
  <p>Library: androidX</p>
  
  <p>I am using a RecyclerView, from the AndroidX Library, in Kotlin and one problem occurred.</p>
  
  <p>Problem: When I clicked on the first showing item, then more items get affected, always after 10 items.</p>
  
  <p>Example: If first item is clicked then items 1, 11, 21,31 will be affected too.</p>
  
  <p>here is code</p>
  
  <pre><code>import android.content.Context
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  import android.widget.Toast
  import androidx.recyclerview.widget.RecyclerView
  import com.jdwebservices.mybigbachat.R
  import com.jdwebservices.mybigbachat.data.products
  import com.squareup.picasso.Picasso
  import kotlinx.android.synthetic.main.product_row.view.*
  import kotlin.collections.ArrayList
  
  
  class product_adapter(var contet:Context, var catlist: ArrayList&lt;products&gt;): RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt;(){
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
          val v:View=LayoutInflater.from(contet).inflate(R.layout.product_row,parent,false)
          return clientHolders(v)
      }
      override fun getItemCount(): Int {
          return catlist.size
      }
  
      override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
          holder.itemView.setOnClickListener { }
           (holder as clientHolders).bind(
             catlist[position].product_name_app_english,
             catlist[position].product_image,
             catlist[position].mrp,
             catlist[position].sale_rate,
               position
         )
      }
  
      class clientHolders(itemView: View): RecyclerView.ViewHolder(itemView)
      {
          val BASE_URL = "https://mybachatbasket.xyz/"
          var counter = -1
          fun bind(
              product_name_app_english: String,
              product_image: String,
              mrp: Int,
              sale_rate: Int,
              products: Int
          ) {
              if (counter == -1) {
                  itemView.add_1.visibility = View.VISIBLE
                  itemView.add_to_cart.visibility = View.GONE
              }
              var pos = adapterPosition
              if(pos == products){
              itemView.product_name.text = product_name_app_english
  
              itemView.mrp_full.visibility = View.VISIBLE
              itemView.mrp.text = mrp.toString()
              itemView.sale_rate.text = sale_rate.toString()
  
              var eb: String = BASE_URL + "admin/resource/uploads/" + product_image
              eb = eb.replace(" ", "%20")
              Picasso.get().load(eb).into(itemView.product_image)
  
              itemView.add_1.setOnClickListener {
  
                  counter = 1
                   Toast.makeText(itemView.context, pos.toString(),Toast.LENGTH_LONG).show()
                 // Toast.makeText(itemView.context, products.toString(), Toast.LENGTH_LONG).show()
                  //  add_cart(product_id,category_id,counter)
  if (pos &gt;= 0) {
      itemView.add_1.visibility = View.GONE
      itemView.add_to_cart.visibility = View.VISIBLE
      itemView.count.text = counter.toString()
  }else{
      itemView.add_1.visibility = View.VISIBLE
      itemView.add_to_cart.visibility = View.GONE
  
  }
  
              }
  
              itemView.add.setOnClickListener {
  
                  counter++
                  itemView.count.text = counter.toString()
  
              }
              itemView.delete.setOnClickListener {
  
                  counter--
                  itemView.count.text = counter.toString()
                  //  updtae_cart(last_id,counter);
                  if (counter == 0) {
                      itemView.add_1.visibility = View.VISIBLE
                      itemView.add_to_cart.visibility = View.GONE
                  }
  
              }
  
          }
          }
  
      }
  
  
  }
  </code></pre>