@Override
 public void onClick(View v) {
   for (Pair<View, View> pair : tabs) {
     if (pair.first == v) {
       int pageIndex = adapter.getIndexOfItem(pair.second);
       if (pageIndex == pager.getCurrentItem()) {
         if (v instanceof Checkable) {
           ((Checkable) v).setChecked(true);
         }
       } else {
         pager.setCurrentItem(pageIndex, isPageSmoothScroll);
       }
       break;
     }
   }
 }
  public boolean removeTab(int index) {
    if (index < 0 || index >= tabs.size()) {
      return false;
    }

    Pair<View, View> tab = tabs.remove(index);
    if (tab != null) {
      itemBar.removeView(tab.first);
      adapter.remove(adapter.getIndexOfItem(tab.second));
      if (selector != null) {
        selector.remove(index);
      }
      onGlobalLayout();
      return true;
    }
    return false;
  }