pivotal/robolectric — pull request #167 by roberttaylor426 (2011-12-13 17:54:00+00:00)
Title: Added support to ShadowAdapterView for firing OnItemSelectedListener.onNothingSelected() when necessary

As described in the [Android documentation](http://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html#onNothingSelected(android.widget.AdapterView), onNothingSelected should be called when the adapter becomes empty. My change does this.

I also added a small check inside setSelection() to ignore values less than zero (like AdapterView.INVALID_POSITION). Looking at the Android source for AbsSpinner and ListView, this is essentially what it does. Previously an ArrayIndexOutOfBoundsException was being thrown by Robolectric.