title: How can I play mp3 from recyclerview using Kotlin?
body: <p>so I am trying to play an audio file from the raw folder by using a button that found in recyclerview but I tried everything and nothing seems to work for me
  can you please help me and thanks in advance </p>
  
  <p>P.C. this is a sample just to Know how to add an audio file in a recyclerview hopefully I will be adding more so if you have any tutorials on to add progress bar, image buttons... etc in recyclerview please share it with me  </p>
  
  <p>here is my progress so far</p>
  
  <p><strong>my Recyclerview Adater</strong></p>
  
  <pre><code>class shaikh( val context: Context, val names: ArrayList&lt;String&gt;, val images: ArrayList&lt;Int&gt;): RecyclerView.Adapter&lt;ViewHolder&gt;() {
  
  private  var mediaPlayer: MediaPlayer? = null
  
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
      val layoutInflater = LayoutInflater.from(parent.context)
      val callXml = layoutInflater.inflate(R.layout.quranvoice,parent, false)
      return ViewHolder(callXml)
  }
  
  
  override fun getItemCount(): Int {
      return names.size
  }
  
  override fun onBindViewHolder(holder: ViewHolder, position: Int) {
  
      holder.itemView.ShaikhName.text = names.get(position)
      holder.itemView.Shaikh.setImageResource(images.get(position))
      holder.itemView.setOnClickListener {
        when(position){
            0-&gt;{
                holder.itemView.voice.setOnClickListener {
                    if (mediaPlayer != null){
                        mediaPlayer = MediaPlayer.create(context, R.raw.abdelbasset)
                        mediaPlayer?.start()
                    }
  
                }
  
            }
            1-&gt;{
                Toast.makeText(context,"الشيخ ناصر",Toast.LENGTH_LONG).show()
  
            }
        }
      }
  }
  
  
  
  }
  
  public class ViewHolder (view: View) : RecyclerView.ViewHolder(view) {
  
      fun ViewHolder( ){
      }
  }
  </code></pre>
  
  <p><strong>my Activity</strong></p>
  
  <pre><code> var texts: ArrayList&lt;String&gt; = ArrayList()
  var images : ArrayList&lt;Int&gt; = ArrayList()
  
    // nothing is in here except the onCreate method 
  
  val Adapter = shaikh(this, texts, images)
     QuranVoice.layoutManager = LinearLayoutManager(this, RecyclerView.HORIZONTAL, true)
     QuranVoice.setHasFixedSize(true)
     QuranVoice.setAdapter( Adapter)
     QuranVoice.addOnScrollListener(CenterScrollListener())
     loadData()
  
    private fun loadData() {
      texts.add("الشيخ عبدالباسط عبدالصمد - رحمه الله-")
      images.add(R.drawable.abdelbasset_abdessamad)
  
  
      texts.add("الشيخ خالد مغمسي")
      images.add(R.drawable.ic_esha_time)
      texts.add("الشيخ خالد مغمسي")
      images.add(R.drawable.ic_dhur_time)
  
  }
  </code></pre>