Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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