title: Android - Scrolling through ListView leads to Out of Bounds Exception
body: <p>I'm working on an application that primarily consists of a list view. It's backed up by my own custom array adapter whose size changes every 5 seconds. If I scroll through the list view as the array adapter changes from a greater size to a lesser size, I get an out of bounds exception. It makes sense to me why this occurs (since I'm scrolling at a position beyond the new array size), but I was wondering if there was a good way to debug it. I can't seem to come to a clear conclusion, and I was wondering if I could get some help.</p>
  
  <p>I update the adapter using the following asyncTask...</p>
  
  <pre><code>public class myTask extends AsyncTask&lt;Void, Void, Void&gt;{
  
          @Override
          protected Void doInBackground(Void... params) {
              while(isRunning){
                  myData.clear();
                  getData();
                  publishProgress();
                  SystemClock.sleep(5000);
              }
              return null;
          }
  
          protected void onProgressUpdate(Void...progress){
              listAdapter.notifyDataSetChanged();
  
          }     
  }
  </code></pre>
  
  <p><code>myData</code> is the ArrayList that supports <code>listAdapter</code> and <code>getData()</code> is the function that populates <code>myData</code> with the relevant info that will eventually be displayed in my list view.</p>
  
  <p>Is there a good way to tackle this problem?</p>
  
  <p>Regards</p>