public void addTabs(TabInfo... tabInfos) {
    if (tabInfos == null || tabInfos.length < 1) {
      return;
    }

    for (TabInfo tabInfo : tabInfos) {
      if (tabInfo == null) {
        break;
      }

      View page = tabInfo.getPage();
      View item = tabInfo.getItem();

      item.setOnClickListener(onSelectorClickListener);
      if (page instanceof Pageable) {
        Pageable pageable = (Pageable) page;
        pageable.onInit(this);
      }

      ViewGroup.LayoutParams itemParams = tabInfo.getItemParams();
      if (itemParams == null) {
        itemBar.addView(item);
      } else {
        itemBar.addView(item, itemParams);
      }
      adapter.add(page);

      tabs.add(new Pair<View, View>(item, page));
    }

    onGlobalLayout();
  }
  public void addTab(int index, TabInfo tabInfo) {
    if (tabInfo == null) {
      return;
    }

    View page = tabInfo.getPage();
    View item = tabInfo.getItem();

    item.setOnClickListener(onSelectorClickListener);
    if (page instanceof Pageable) {
      Pageable pageable = (Pageable) page;
      pageable.onInit(this);
    }

    if (index < 0 || index >= adapter.getCount()) {
      ViewGroup.LayoutParams itemParams = tabInfo.getItemParams();
      if (itemParams == null) {
        itemBar.addView(item);
      } else {
        itemBar.addView(item, itemParams);
      }
      adapter.add(page);
    } else {
      ViewGroup.LayoutParams itemParams = tabInfo.getItemParams();
      if (itemParams == null) {
        itemBar.addView(item, index);
      } else {
        itemBar.addView(item, index, itemParams);
      }
      adapter.add(index, page);
    }

    tabs.add(new Pair<View, View>(item, page));

    onGlobalLayout();
  }