title: notifyDataSetChanged() causes IndexOutOfBoundsException
body: <p>Here's a shortened version of my code.</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  private ArrayList&lt;String&gt; entry = new ArrayList&lt;String&gt;();
  private String[] entryString = new String[11];
  private ArrayAdapter&lt;String&gt; aa;
  private ListView entryListView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      entryListView = (ListView) findViewById(R.id.listView1);
      int listID = R.layout.entry_layout;
      aa = new EntryAdapter(this, listID, entry);
      entryListView.setAdapter(aa);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      switch (id) {
      case R.id.action_add: {
          Intent intent = new Intent(MainActivity.this, AddActivity.class);
          startActivityForResult(intent, 1);
          break;
      }
      }
      return super.onOptionsItemSelected(item);
  }
  
  @Override
  public void onActivityResult(int rc, int resc, Intent i) {
      super.onActivityResult(rc, resc, i);
      entryString = i.getStringArrayExtra("Entry");
      this.onNewItemAdded(entryString);
  }
  
  public void onNewItemAdded(String[] _entry){
      String key = new String();
      key = _entry[0];
      entry.add(key);
      aa.notifyDataSetChanged();   //Runs without crashing when this is removed.
  }
  </code></pre>
  
  <p>The adapter class is,</p>
  
  <pre><code>@SuppressLint("Instantiatable")
  public class EntryAdapter extends ArrayAdapter&lt;String&gt;{
  
  private ArrayList&lt;String&gt; entries;
  int count;
  int resource;
  public EntryAdapter(Context _context, int _resource, List&lt;String&gt; _entries){
      //TODO Auto-generated constructor stub
      super(_context, _resource, R.id.key, _entries);
      this.resource = _resource;
      this.entries = new ArrayList&lt;String&gt;(_entries);
      this.count = 0;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
  
      if (convertView == null) {
          String inflater = Context.LAYOUT_INFLATER_SERVICE;
          LayoutInflater li;
          li = (LayoutInflater) getContext().getSystemService(inflater);
          row = li.inflate(resource, parent, false);
      }
  
      TextView keyView = (TextView) row.findViewById(R.id.key);
      TextView siteView = (TextView) row.findViewById(R.id.site);
  
      for(int c=0; c&lt;11; c++){
          while(!entries.get(c).toString().equals("")){
              count++;
          }
      }
  
      keyView.setText(entries.get(position));
      siteView.setText(count + "sources");
  
      return row;
  }
  } 
  </code></pre>
  
  <p>By commenting the aa.notifyDataSetChanged() call in the MainActivity, the application runs without crashing but throws an</p>
  
  <blockquote>
    <p>IndexOutOfBoundsException: Invalid index 0, size is 0</p>
  </blockquote>
  
  <p>when it is not commented.</p>
  
  <p>PS: The XML is perfectly fine.</p>
  
  <p>Edit:</p>
  
  <p>Here's the log</p>
  
  <blockquote>
    <p>03-18 18:38:03.840: E/AndroidRuntime(6052): FATAL EXCEPTION: main
    03-18 18:38:03.840: E/AndroidRuntime(6052): Process: com.FirstClass.alert, PID: 6052
    03-18 18:38:03.840: E/AndroidRuntime(6052): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at java.util.ArrayList.get(ArrayList.java:308)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at com.FirstClass.netalert.EntryAdapter.getView(EntryAdapter.java:66)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.AbsListView.obtainView(AbsListView.java:2263)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.ListView.makeAndAddView(ListView.java:1790)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.ListView.fillDown(ListView.java:691)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.ListView.fillFromTop(ListView.java:752)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.ListView.layoutChildren(ListView.java:1630)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.AbsListView.onLayout(AbsListView.java:2091)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:502)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.View.layout(View.java:14822)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewGroup.layout(ViewGroup.java:4631)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.Choreographer.doFrame(Choreographer.java:544)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.os.Handler.handleCallback(Handler.java:733)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.os.Handler.dispatchMessage(Handler.java:95)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.os.Looper.loop(Looper.java:136)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at android.app.ActivityThread.main(ActivityThread.java:5021)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at java.lang.reflect.Method.invokeNative(Native Method)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at java.lang.reflect.Method.invoke(Method.java:515)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
    03-18 18:38:03.840: E/AndroidRuntime(6052):     at dalvik.system.NativeStart.main(Native Method)</p>
  </blockquote>