title: Add Image Into RecyclerView Android Using Kotlin
body: <p>how I can add image from drawable dynamically into recycler view using kotlin? Here is my <em>MainActivity.kt</em></p>
  <pre><code>class MainActivity : AppCompatActivity() {
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
  
      val binding: ActivityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)
      binding.get = Get()
  
      //parse array klaxon
      var products = Klaxon().parseArray&lt;ProductData&gt;(addProducts())
      if (!products!!.isEmpty()) {
          product_list.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
          product_list.hasFixedSize()
          product_list.adapter = ProductAdapter(products, { item: ProductData-&gt; item })
      }
  }
  
  private fun addProducts(): String {
      return application.assets.open(&quot;product_data.json&quot;).bufferedReader().use{
          it.readText()
      }
  }
  
  private fun read(): String {
      return application.assets.open(&quot;text.json&quot;).bufferedReader().use{
          it.readText()
      }
  }
  
  fun Get() : Data {
      val data = Klaxon()
              .parse&lt;Data&gt;(read())
      if(data == null) return Data(
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;,
              &quot;&quot;
      )
      return data
  }
  }
  </code></pre>
  <p>Here is my adapter <em>ProductAdapter</em></p>
  <pre><code>class ProductAdapter (var productList: List&lt;ProductData&gt;, var clickListener: (ProductData) -&gt; Unit) :
      RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt;() {
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
      var v = LayoutInflater.from(parent.context).inflate(R.layout.product_lists_item, parent, false)
      return ListHolder(v)
  }
  
  override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
      (holder as ListHolder).bind(productList[position], clickListener)
  }
  
  override fun getItemCount() = productList.size
  
  class ListHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
      fun bind(_list: ProductData, clickListener: (ProductData) -&gt; Unit) {
          itemView.product_item.text = _list.product_name
          itemView.setOnClickListener { clickListener(_list) }
      }
  }
  }
  </code></pre>
  <p>and here is my data class, <em>ProductData.kt</em></p>
  <pre><code>data class ProductData (
      var product_name: String
  //do I need to declare the image here?
  )
  </code></pre>
  <p>and here I fetch the data using JSON, <em>product_data.json</em></p>
  <pre><code>[ {
  &quot;product_name&quot;: &quot;A&quot;,
  &quot;product_image&quot;: &quot;A.jpg&quot;
    },
    {
      &quot;product_name&quot;: &quot;B&quot;,
      &quot;product_image&quot;: &quot;B.jpg&quot;
    },
    {
      &quot;product_name&quot;: &quot;C&quot;,
      &quot;product_image&quot;: &quot;C.jpg&quot;
    }
  ]
  </code></pre>
  <p>I was able to show the recycler view, but not with image data. I need to put image in top of product_name.
  Should I use picasso for it? or not? Thanks in advance.</p>