コード例 #1
0
  @SuppressWarnings("MagicConstant")
  private IcsLinearLayout findOrInitializeLayout(final View convertView) {
    IcsLinearLayout layout;

    if (convertView == null || !(convertView instanceof IcsLinearLayout)) {
      layout = new IcsLinearLayout(context, null);
      if (listView.isDebugging()) layout.setBackgroundColor(Color.parseColor("#83F27B"));

      layout.setShowDividers(IcsLinearLayout.SHOW_DIVIDER_MIDDLE);
      layout.setDividerDrawable(
          context.getResources().getDrawable(R.drawable.item_divider_horizontal));

      layout.setLayoutParams(
          new AbsListView.LayoutParams(
              AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
    } else layout = (IcsLinearLayout) convertView;

    // Clear all layout children before starting
    for (int j = 0; j < layout.getChildCount(); j++) {
      IcsLinearLayout tempChild = (IcsLinearLayout) layout.getChildAt(j);
      linearLayoutPool.put(tempChild);
      for (int k = 0; k < tempChild.getChildCount(); k++) viewPool.put(tempChild.getChildAt(k));
      tempChild.removeAllViews();
    }
    layout.removeAllViews();

    return layout;
  }
コード例 #2
0
 public void notifyDataSetChanged() {
   mTabLayout.removeAllViews();
   PagerAdapter adapter = mViewPager.getAdapter();
   IconPagerAdapter iconAdapter = null;
   if (adapter instanceof IconPagerAdapter) {
     iconAdapter = (IconPagerAdapter) adapter;
   }
   final int count = adapter.getCount();
   for (int i = 0; i < count; i++) {
     CharSequence title = adapter.getPageTitle(i);
     if (title == null) {
       title = EMPTY_TITLE;
     }
     int iconResId = 0;
     if (iconAdapter != null) {
       iconResId = iconAdapter.getIconResId(i);
     }
     addTab(i, title, iconResId);
   }
   if (mSelectedTabIndex > count) {
     mSelectedTabIndex = count - 1;
   }
   setCurrentItem(mSelectedTabIndex);
   requestLayout();
 }
コード例 #3
0
 public void removeAllTabs() {
   mTabLayout.removeAllViews();
   if (mTabSpinner != null) {
     ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
   }
   if (mAllowCollapse) {
     requestLayout();
   }
 }
コード例 #4
0
 public void notifyDataSetChanged() {
   mIconsLayout.removeAllViews();
   IconPagerAdapter iconAdapter = (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();
 }