@Override protected void initialized() { Fragment fragment1 = new One_MingZhanFragment_1(); Fragment fragment2 = new One_JingXuanFragment(); Fragment fragment3 = new One_RenQiFragment(); Fragment fragment4 = new CategoryFragment(); Bundle bundle = new Bundle(); Object[] obj = new Object[] {"tools"}; bundle.putSerializable(MainActivity.KEY, obj); fragment4.setArguments(bundle); List<Fragment> mFragments = new ArrayList<Fragment>(); mFragments.add(fragment1); mFragments.add(fragment2); mFragments.add(fragment3); mFragments.add(fragment4); List<String> tabTexts = new ArrayList<String>(); tabTexts.add(getResources().getString(R.string.one_1)); tabTexts.add(getResources().getString(R.string.one_2)); tabTexts.add(getResources().getString(R.string.one_3)); tabTexts.add(getResources().getString(R.string.one_4)); // 设置样式 mAbSlidingTabView.setTabTextColor(getResources().getColor(R.color.white_color)); mAbSlidingTabView.setTabSelectColor(getResources().getColor(R.color.white_color)); mAbSlidingTabView.setTabSelectTextSize(35); mAbSlidingTabView.setTabBackgroundResource(R.color.transparent); mAbSlidingTabView.setTabLayoutBackgroundResource(R.color.main_color); mAbSlidingTabView.setTabBackgroundResourceSelect(R.drawable.tab_select_bg); // 演示增加一组 mAbSlidingTabView.addItemViews(tabTexts, mFragments); mAbSlidingTabView.setTabPadding(10, 0, 10, 20); }
@Override protected void setupViews(View parentView) { mAbSlidingTabView = (AbSlidingTabView_fix) parentView.findViewById(R.id.mAbSlidingTabView); // 缓存数量 mAbSlidingTabView.getViewPager().setOffscreenPageLimit(3); }