code: @Override
      public void setAdapter(SpinnerAdapter adapter) {
          if (null != mAdapter) {
              mAdapter.unregisterDataSetObserver(mDataSetObserver);
              resetList();
          }
  
          mAdapter = adapter;
  
          mOldSelectedPosition = INVALID_POSITION;
          mOldSelectedRowId = INVALID_ROW_ID;
  
          if (mAdapter != null) {
              mOldItemCount = mItemCount;
              mItemCount = mAdapter.getCount();
              checkFocus();
  
              mDataSetObserver = new AdapterDataSetObserver();
              mAdapter.registerDataSetObserver(mDataSetObserver);
  
              int position = mItemCount > 0 ? 0 : INVALID_POSITION;
  
              setSelectedPositionInt(position);
              setNextSelectedPositionInt(position);
  
              if (mItemCount == 0) {
                  // Nothing selected
                  checkSelectionChanged();
              }
  
          } else {
              checkFocus();
              resetList();
              // Nothing selected
              checkSelectionChanged();
          }
  
          requestLayout();
      }
docs: The Adapter is used to provide the data which backs this Spinner.
  It also provides methods to transform spinner items based on their position
  relative to the selected item.
  @param adapter The SpinnerAdapter to use for this Spinner