use of carbon.widget.ViewPagerIndicator in project Carbon by ZieIony.
the class TabsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initToolbar();
ViewPager pager = findViewById(R.id.pager);
pager.setAdapter(new PagerAdapter() {
@Override
public CharSequence getPageTitle(int position) {
return "Page " + position;
}
View getView(int position, ViewPager pager) {
return new RelativeLayout(pager.getContext(), null, R.attr.carbon_cardViewStyle);
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@Override
public int getCount() {
return 7;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ViewPager pager = (ViewPager) container;
View view = getView(position, pager);
pager.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object view) {
container.removeView((View) view);
}
});
TabLayout tabs = findViewById(R.id.tabs);
tabs.setViewPager(pager);
ViewPagerIndicator indicator = findViewById(R.id.indicator);
indicator.setViewPager(pager);
}
Aggregations