Ejemplo n.º 1
0
  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));
  }
 public void notifyDataSetChanged() {
   mIconsLayout.removeAllViews();
   com.viewpagerindicator.IconPagerAdapter iconAdapter =
       (com.viewpagerindicator.IconPagerAdapter) mViewPager.getAdapter();
   int count = iconAdapter.getCount();
   for (int i = 0; i < count; i++) {
     ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle);
     view.setImageResource(iconAdapter.getIconResId(i));
     mIconsLayout.addView(view);
   }
   if (mSelectedIndex > count) {
     mSelectedIndex = count - 1;
   }
   setCurrentItem(mSelectedIndex);
   requestLayout();
 }