Ejemplo n.º 1
0
  /**
   * Add a tab.
   *
   * @param tabSpec Specifies how to create the indicator and content.
   */
  public void addTab(TabSpec tabSpec) {

    if (tabSpec.mIndicatorStrategy == null) {
      throw new IllegalArgumentException("you must specify a way to create the tab indicator.");
    }

    if (tabSpec.mContentStrategy == null) {
      throw new IllegalArgumentException("you must specify a way to create the tab content");
    }
    View tabIndicator = tabSpec.mIndicatorStrategy.createIndicatorView();
    tabIndicator.setOnKeyListener(mTabKeyListener);

    // If this is a custom view, then do not draw the bottom strips for
    // the tab indicators.
    if (tabSpec.mIndicatorStrategy instanceof ViewIndicatorStrategy) {
      mTabWidget.setDrawBottomStrips(false);
    }
    mTabWidget.addView(tabIndicator);
    mTabSpecs.add(tabSpec);

    if (mCurrentTab == -1) {
      setCurrentTab(0);
    }
  }