code: public void setAdapter(PagerAdapter adapter) {
      if (mAdapter != null) {
        mAdapter.unregisterDataSetObserver(mObserver);
        mAdapter.startUpdate(this);
        mAdapter.destroyItem(this, mCurrentPosition, mCurrentFragment);
        mAdapter.finishUpdate(this);
        mCurrentPosition = 0;
      }
  
      mAdapter = adapter;
      mExpectedAdapterCount = 0;
  
      if (mAdapter != null) {
        if (mObserver == null) {
          mObserver = new PagerObserver();
        }
        mAdapter.registerDataSetObserver(mObserver);
        mPopulatePending = false;
        final boolean wasFirstLayout = mFirstLayout;
        mFirstLayout = true;
        mExpectedAdapterCount = mAdapter.getCount();
        if (mRestoredCurItem >= 0) {
          mAdapter.restoreState(mRestoredAdapterState, mRestoredClassLoader);
          setCurrentItemInternal(mRestoredCurItem, true);
          mRestoredCurItem = -1;
          mRestoredAdapterState = null;
          mRestoredClassLoader = null;
        } else if (!wasFirstLayout) {
          populate();
        } else {
          requestLayout();
        }
      }
    }
docs: Set a PagerAdapter that will supply views for this pager as needed.
  
  @param adapter Adapter to use