title: Same Material Chips are added again to ChipGroup when RecyclerView is scrolled up/down
body: <p>As the official <a href="https://material.io/components/chips" rel="nofollow noreferrer">material.io documentation</a> says:</p>
  <blockquote>
  <p>Chips are compact elements that represent an input, <em>attribute</em>, or action.</p>
  </blockquote>
  <p>I want to add chips as <em>attributes (tags)</em> for any blog post, a recyclerview is used to show the list of blog posts:</p>
  <p>item_post.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;com.google.android.material.card.MaterialCardView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:id=&quot;@+id/mcv_container_item_blog&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:focusable=&quot;true&quot;
      android:clickable=&quot;true&quot;
      android:background=&quot;?selectableItemBackground&quot;
      app:cardUseCompatPadding=&quot;true&quot;&gt;
  
      &lt;androidx.appcompat.widget.LinearLayoutCompat
          android:id=&quot;@+id/llc_container_item_project&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:padding=&quot;@dimen/item_margin&quot;
          android:orientation=&quot;vertical&quot;&gt;
  
          &lt;androidx.appcompat.widget.AppCompatImageView
              android:id=&quot;@+id/aciv_item_post_image&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;@dimen/item_project_Image_size&quot;
              android:scaleType=&quot;centerCrop&quot;
              android:adjustViewBounds=&quot;true&quot;
              app:srcCompat=&quot;@drawable/drawer_bg&quot;/&gt;
  
          &lt;com.google.android.material.textview.MaterialTextView
              android:id=&quot;@+id/mtv_item_post_title&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layout_marginTop=&quot;@dimen/item_margin&quot;
              android:textAppearance=&quot;@style/TextAppearance.AppCompat.Large&quot;
              android:textColorHighlight=&quot;@color/design_default_color_background&quot;
              android:text=&quot;Chameleon UI Kit&quot; /&gt;
  
          &lt;com.google.android.material.textview.MaterialTextView
              android:id=&quot;@+id/mtv_item_post_date&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:textColor=&quot;@color/red_lighten&quot;
              android:layout_marginTop=&quot;@dimen/user_name_margin_start&quot;
              android:layout_marginEnd=&quot;@dimen/user_name_margin_start&quot;
              android:layout_marginBottom=&quot;@dimen/user_name_margin_start&quot;
              android:text=&quot;10 Sept&quot;/&gt;
  
          &lt;com.google.android.material.textview.MaterialTextView
              android:id=&quot;@+id/mtv_item_post_short_description&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:textAppearance=&quot;@style/TextAppearance.AppCompat.Small&quot;
              android:text=&quot;@string/about_me&quot; /&gt;
  
          &lt;include layout=&quot;@layout/item_divider&quot;/&gt;
  
          &lt;HorizontalScrollView
              android:id=&quot;@+id/hsv_item_post_tags&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:scrollbars=&quot;none&quot;&gt;
  
              &lt;com.google.android.material.chip.ChipGroup
                  android:id=&quot;@+id/cg_item_post_tags&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  app:singleLine=&quot;true&quot;/&gt;
  
          &lt;/HorizontalScrollView&gt;
  
      &lt;/androidx.appcompat.widget.LinearLayoutCompat&gt;
  
  &lt;/com.google.android.material.card.MaterialCardView&gt;
  </code></pre>
  <p>then the PostAdapter class:</p>
  <pre><code>class PostAdapter(
      private val postList: List&lt;Post&gt;
  ): RecyclerView.Adapter&lt;PostAdapter.PostViewHolder&gt;()  {
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PostViewHolder {
          val view = LayoutInflater.from(parent.context).inflate(R.layout.item_post, parent, false)
          return PostViewHolder(view)
      }
  
      override fun onBindViewHolder(holder: PostViewHolder, position: Int) {
          val post = postList[position]
  
          holder.postTitle.text = post.postTitle
          holder.postDescription.text = post.postDescription
          holder.postDate.text = post.postDate
  
          val tagChip = Chip(holder.itemView.context).apply {
              id = View.generateViewId()
              text = &quot;label&quot;
          }
  
          holder.postTagsChipGroup.addView(tagChip)
  
      }
  
      override fun getItemCount(): Int {
          return postList.size
      }
  
      inner class PostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
  
          val postTitle: MaterialTextView = itemView.findViewById(R.id.mtv_item_post_title)
          val postDescription: MaterialTextView = itemView.findViewById(R.id.mtv_item_post_short_description)
          val postTagsChipGroup: ChipGroup = itemView.findViewById(R.id.cg_item_post_tags)
          val postDate: MaterialTextView = itemView.findViewById(R.id.mtv_item_post_date)
  
      }
  
  }
  </code></pre>
  <p>at this stage a weird thing happens, when I 'scroll recyclerview' other <code>Chips</code> are added from nowhere as you can see this behavior in gif below:</p>
  <img src="https://i.stack.imgur.com/HhwFT.gif" width="250" />
  <p>how to avoid such behavior, what changes should I make in adapters <code>onBindViewHolder</code> method?</p>