title: Adding new item to ArrayAdapter
body: <p>I want to add a new item to my <code>arrayadapter</code> and then for it to render in my view. After digging online, I noticed that the ArrayAdapter class keeps its own version of the <code>arraylist</code> as mentioned here: <a href="https://stackoverflow.com/questions/14503006/android-listview-not-refreshing-after-notifydatasetchanged">Android ListView not refreshing after notifyDataSetChanged</a>.</p>
  
  <p>Heres my code:</p>
  
  <p><code>The add new item code:</code></p>
  
  <pre><code>public void addRecordSet(View view) {
  
      RecordStats recordStats = new RecordStats();
      recordStats.RecordID = mRecord.id;
  
      long recordStatId = mDatabaseHelper.addRecordStats(recordStats);
      recordStats.ID = (int) recordStatId;
  
      recordStatsList.add(recordStats);
      mAdapter.swapRecordFormList(recordStatsList);
  }
  </code></pre>
  
  <p><code>The arrayadapter code:</code></p>
  
  <pre><code>    public void swapRecordFormList(ArrayList&lt;RecordStats&gt; recordStatsList) {
          mRecordStatsList = recordStatsList;
          notifyDataSetChanged();
      }
  </code></pre>
  
  <p>However, i get this error:</p>
  
  <pre><code>Process: com.example.andyxu.enzo3, PID: 19289
  
  java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
      at java.util.ArrayList.get(ArrayList.java:437)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>EDIT:</p>
  
  <pre><code>@NonNull
  @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
      View recordForm = convertView;
      if (recordForm == null) {
          recordForm = LayoutInflater.from(mContext).inflate(R.layout.custom_record_form, parent, false);
      }
  
      RecordStats currentRecord = mRecordStatsList.get(position);
  
      EditText reps = (EditText) recordForm.findViewById(R.id.reps);
      if (currentRecord.Reps &gt; 0) {
          reps.setText(String.valueOf(currentRecord.Reps));
      }
  
      EditText weight = (EditText) recordForm.findViewById(R.id.weight);
      if (currentRecord.Weight &gt; 0) {
          weight.setText(String.valueOf(currentRecord.Weight));
      }
      return recordForm;
  }
  </code></pre>