use of com.test.banner.util.TabLayoutMediator in project banner by youth5201314.
the class Vp2FragmentRecyclerviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vp2_fragment_recyclerview);
ButterKnife.bind(this);
viewPager2.setAdapter(new FragmentStateAdapter(this) {
@NonNull
@Override
public Fragment createFragment(int position) {
if (position == 0) {
return BannerListFragment.newInstance(position);
} else if (position == 1) {
return BlankFragment.newInstance();
} else {
return BannerFragment.newInstance();
}
}
@Override
public int getItemCount() {
return 3;
}
});
new TabLayoutMediator(mTabLayout, viewPager2, (tab, position) -> {
tab.setText("页面" + position);
}).attach();
mBanner.addBannerLifecycleObserver(this).setAdapter(new ImageAdapter(DataBean.getTestData())).setIntercept(false).setIndicator(new CircleIndicator(this));
}
Aggregations