title: Object reference not set to an instance of an object when trying to populate Xamarin Android TextView on fragmenrt from arrary
body: <p>I'm getting the error <code>System.NullReferenceException: Object reference not set to an instance of an object</code> when I try to reference a <code>TextView</code> from my fragment. It happens at runtime.</p>
  
  <p><strong>Fragment</strong> </p>
  
  <pre><code>public class Fragment1 : Fragment
  {
      private int checkNumber = 0;
      private string[] updateTitleArray = new string[10];
      private string[] updateBodyArray = new string[10];
      private TextView updatesTitle0;
      private TextView updatesTitle1;
      private TextView updatesTitle2;
      private TextView updatesTitle3;
      private TextView updatesTitle4;
      private TextView updatesTitle5;
      private TextView updatesTitle6;
      private TextView updatesTitle7;
      private TextView updatesTitle8;
      private TextView updatesTitle9;
  
      private TextView updateBody0;
      private TextView updateBody1;
      private TextView updateBody2;
      private TextView updateBody3;
      private TextView updateBody4;
      private TextView updateBody5;
      private TextView updateBody6;
      private TextView updateBody7;
      private TextView updateBody8;
      private TextView updateBody9;
  
  
  
      public override void OnCreate(Bundle savedInstanceState)
      {
          base.OnCreate(savedInstanceState);
          fillUpdates(updateTitleArray, updateBodyArray);
      }
  
      public static Fragment1 NewInstance()
      {
          var frag1 = new Fragment1 { Arguments = new Bundle() };
          return frag1;
      }
  
  
      public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
          var ignored = base.OnCreateView(inflater, container, savedInstanceState);
          return inflater.Inflate(Resource.Layout.fragment1, null);
      }
  
      public void fillUpdates(string[] updatetitlearray, string[] updatebodyarray)
      {
          //increment1 so if block skips here
          checkNumber = 1;
  
          //fill updatesArray
          updateTitleArray = updatetitlearray;
          updateBodyArray = updatebodyarray;
  
          updatesTitle0 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title0);
          updatesTitle1 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title1);
          updatesTitle2 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title2);
          updatesTitle3 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title3);
          updatesTitle4 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title4);
          updatesTitle5 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title5);
          updatesTitle6 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title6);
          updatesTitle7 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title7);
          updatesTitle8 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title8);
          updatesTitle9 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_title9);
  
          updateBody0 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body0);
          updateBody1 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body1);
          updateBody2 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body2);
          updateBody3 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body3);
          updateBody4 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body4);
          updateBody5 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body5);
          updateBody6 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body6);
          updateBody7 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body7);
          updateBody8 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body8);
          updateBody9 = View.FindViewById&lt;TextView&gt;(Resource.Id.update_body9);
  
  
          updatesTitle0.Text = updateTitleArray[0].ToString();
          updatesTitle1.Text = updateTitleArray[1].ToString();
          updatesTitle2.Text = updateTitleArray[2].ToString();
          updatesTitle3.Text = updateTitleArray[3].ToString();
          updatesTitle4.Text = updateTitleArray[4].ToString();
          updatesTitle5.Text = updateTitleArray[5].ToString();
          updatesTitle6.Text = updateTitleArray[6].ToString();
          updatesTitle7.Text = updateTitleArray[7].ToString();
          updatesTitle8.Text = updateTitleArray[8].ToString();
          updatesTitle9.Text = updateTitleArray[9].ToString();
  
          updateBody0.Text = updateBodyArray[0].ToString();
          updateBody1.Text = updateBodyArray[1].ToString();
          updateBody2.Text = updateBodyArray[2].ToString();
          updateBody3.Text = updateBodyArray[3].ToString();
          updateBody4.Text = updateBodyArray[4].ToString();
          updateBody5.Text = updateBodyArray[5].ToString();
          updateBody6.Text = updateBodyArray[6].ToString();
          updateBody7.Text = updateBodyArray[7].ToString();
          updateBody8.Text = updateBodyArray[8].ToString();
          updateBody9.Text = updateBodyArray[9].ToString();
      }
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>   &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:padding="10dp"
          android:fillViewport="false"&gt;
          &lt;LinearLayout
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
          &lt;!--Cardview 1--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:minHeight="60dp"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title0"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body0"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shownbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view2--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title1"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body1"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--cardview 3--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title2"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body2"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 4--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title3"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body3"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 5--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title4"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body4"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 6--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title5"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body5"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 7--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title6"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body6"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 8--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title7"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body7"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 9--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title8"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body8"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;!--card view 10--&gt;
              &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  card_view:cardElevation="8dp"
                  card_view:cardCornerRadius="8dp"
                  android:layout_marginLeft="8dp"
                  android:layout_marginRight="8dp"
                  android:layout_marginTop="8dp"&gt;
                  &lt;GridLayout
                      android:minWidth="25px"
                      android:minHeight="25px"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:columnCount="3"
                      android:rowCount="1"&gt;
                      &lt;LinearLayout
                          android:orientation="vertical"
                          android:layout_gravity="fill"
                          android:layout_row="0"
                          android:layout_column="0"
                          android:padding="16sp"&gt;
                          &lt;TextView
                              android:id="@+id/update_title9"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update 1"
                              android:padding="4sp"
                              android:textSize="24sp"
                              android:textColor="@color/primaryText" /&gt;
                          &lt;TextView
                              android:id="@+id/update_body9"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:text="Update Details Is Shown Here"
                              android:padding="4sp"
                              android:textSize="16sp" /&gt;
                      &lt;/LinearLayout&gt;
                  &lt;/GridLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;/LinearLayout&gt;
      &lt;/ScrollView&gt;
  </code></pre>
  
  <p>I understand that what I am trying to achieve can be implemented with recycler views but I haven't fully understood that, because I am a beginner programmer.</p>