title: How can I have multiple TextViews inside a RecyclerView list item
body: <p>I know that RecyclerView lists are flexible and that it's possible to have multiple views in each item. I can't find any good example code that will help me implement this.</p>
  
  <p>I am trying to implement a simple RecyclerView list with each list item as a custom .xml layout that I have created. What must be done in for the RecyclerView.Adapter to be able to access each different view by its ID from the custom layout file and be able to update each value?</p>
  
  <p>I've basically copied the following code from <a href="https://developer.android.com/guide/topics/ui/layout/recyclerview#Adapter" rel="nofollow noreferrer">Android Docs</a>.</p>
  
  <p>//ScannedDevicesListAdapter.kt</p>
  
  <pre><code>import android.view.LayoutInflater
  import android.view.ViewGroup
  import android.widget.TextView
  import androidx.recyclerview.widget.RecyclerView
  
  class ScannedDevicesListAdapter(private val myDataset: Array&lt;String&gt;) :
      RecyclerView.Adapter&lt;ScannedDevicesListAdapter.ScannedDevicesListViewHolder&gt;() {
  
      // Provide a reference to the views for each data item
      // Complex data items may need more than one view per item, and
      // you provide access to all the views for a data item in a view holder.
      // Each data item is just a string in this case that is shown in a TextView.
      class ScannedDevicesListViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView)
  
      // Create new views (invoked by the layout manager)
      override fun onCreateViewHolder(parent: ViewGroup,
                                      viewType: Int): ScannedDevicesListAdapter.ScannedDevicesListViewHolder {
          // create a new view
          val textView = LayoutInflater.from(parent.context)
              .inflate(R.layout.scanned_devices_list_item, parent, false) as TextView
          // set the view's size, margins, paddings and layout parameters
          return ScannedDevicesListViewHolder(textView)
      }
  
      // Replace the contents of a view (invoked by the layout manager)
      override fun onBindViewHolder(holder: ScannedDevicesListViewHolder, position: Int) {
          // - get element from your dataset at this position
          // - replace the contents of the view with that element
          holder.textView.text = myDataset[position]
      }
  
      // Return the size of your dataset (invoked by the layout manager)
      override fun getItemCount() = myDataset.size
  }
  </code></pre>
  
  <p>Here is the .xml file for my custom view:</p>
  
  <p><a href="https://i.stack.imgur.com/pubt0.png" rel="nofollow noreferrer">Screenshot of the custom list item</a></p>
  
  <p>//scanned_devices_list_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="30dp"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/TextView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              tools:text="Field 1" /&gt;
  
          &lt;TextView
              android:id="@+id/TextView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              tools:text="Field 2" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:orientation="horizontal"&gt;
  
          &lt;TextView
              android:id="@+id/TextView3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              tools:text="Field 3" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>