title: Setting RecyclerView adapter into ViewPager2
body: <p>I've created a RecyclerView with Horizontal Scrolling and PageSnapHelper. Now I think to replace RecyclerView with ViewPager2.? Can I simply set RecyclerView Adapter I've created earlier for new ViewPager2.?</p>
  
  <p>Adapter Class goes here</p>
  
  <pre><code>class QuoteAdapter(
  val context: Context,
  val list: ArrayList&lt;ResultsItem&gt;
  ) : RecyclerView.Adapter&lt;QuoteAdapter.QuoteViewHolder&gt;() {
  
  var i = 0;
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): 
  QuoteViewHolder {
  
      val view = LayoutInflater.from(context)
          .inflate(R.layout.item_quote, parent, false)
      return QuoteViewHolder(view)
  }
  
  override fun getItemCount() = list.size
  
  override fun onBindViewHolder(holder: QuoteViewHolder, position: Int) {
  
  
  
      holder.quote.text = list[position].quoteText
      holder.quote_by.text = "- ${list[position].quoteAuthor}"
  
  
      ColorStore()
  
      if (position == 0) {
          holder.quote_bg.setBackgroundColor(ContextCompat.getColor(context, R.color.md_blue_400))
      } else {
          holder.quote_bg.setBackgroundColor(ContextCompat.getColor(context, colorList.random()))
      }
      holder.quote_bg.setOnClickListener {
          holder.quote_bg.setBackgroundColor(ContextCompat.getColor(context, colorList.random()))
      }
  
  
  
  }
  
  class QuoteViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
      val quote = itemView.quote_text
      val quote_by = itemView.by_text
      val quote_bg = itemView.quote_bg
  }
  </code></pre>
  
  <p>}</p>