Created
December 30, 2016 09:23
-
-
Save manishkpr/388fc8e8c5967e6969a5f7a3a940adde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SlidingFragment extends Fragment { | |
private SlidingTabLayout mSlidingTabLayout; | |
private ViewPager mViewPager; | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
return inflater.inflate(R.layout.fragment_sample, container, false); | |
} | |
@Override | |
public void onViewCreated(View view, Bundle savedInstanceState) { | |
setUpPager(view); | |
setUpTabColor(); | |
} | |
void setUpPager(View view){ | |
mViewPager = (ViewPager) view.findViewById(R.id.viewpager); | |
mViewPager.setAdapter(new TabsPagerAdapter(getActivity())); | |
mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs); | |
mSlidingTabLayout.setViewPager(mViewPager); | |
} | |
void setUpTabColor(){ | |
mSlidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { | |
@Override | |
public int getIndicatorColor(int position) { | |
// TODO Auto-generated method stub | |
return SlidingFragment.this.getResources().getColor(R.color.red); | |
} | |
@Override | |
public int getDividerColor(int position) { | |
// TODO Auto-generated method stub | |
return SlidingFragment.this.getResources().getColor(R.color.red); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment