private void addTab(CharSequence text, int index) {
   final TabView tabView = new TabView(getContext());
   tabView.mIndex = index;
   tabView.setFocusable(true);
   tabView.setOnClickListener(mTabClickListener);
   tabView.setText(text);
   mTabLayout.addView(tabView, new LinearLayout.LayoutParams(WRAP_CONTENT, FILL_PARENT, 1));
 }
Exemplo n.º 2
0
  private void addTab(String text, Drawable icon, int index) {
    // Workaround for not being able to pass a defStyle on pre-3.0
    final TabView tabView = (TabView) mInflater.inflate(R.layout.vpi__tab, null);
    tabView.init(this, text, icon, index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);

    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));
  }
  private void addTab(int index, CharSequence text, int iconResId) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);

    if (iconResId != 0) {
      tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }

    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
  }
  private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
    // Workaround for not being able to pass a defStyle on pre-3.0
    final TabView tabView = (TabView) mInflater.inflate(R.layout.abs__action_bar_tab, null);
    tabView.init(this, tab, forAdapter);

    if (forAdapter) {
      tabView.setBackgroundDrawable(null);
      tabView.setLayoutParams(
          new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, mContentHeight));
    } else {
      tabView.setFocusable(true);

      if (mTabClickListener == null) {
        mTabClickListener = new TabClickListener();
      }
      tabView.setOnClickListener(mTabClickListener);
    }
    return tabView;
  }