TabLayout_ViewPager_Fragment可滑动的
一:先看布局
二:创建VierPagerAdapter
public classVierPagerAdapterextendsFragmentStatePagerAdapter{
privateListmFragment=newArrayList<>();
publicVierPagerAdapter(FragmentManagerfm){
super(fm);
initFragemnts();
}
private voidinitFragemnts(){
mFragment.add(newFragmentInfo("推荐",RecommendFragment.class));
mFragment.add(newFragmentInfo("排行",RankingFragment.class));
mFragment.add(newFragmentInfo("游戏",GameFragment.class));
mFragment.add(newFragmentInfo("分类",CategoryFragment.class));
}
@Override
publicFragmentgetItem(intposition){
try{
return(Fragment)mFragment.get(position).getFragment().newInstance();
}catch(InstantiationExceptione){
e.printStackTrace();
}catch(IllegalAccessExceptione){
e.printStackTrace();
}
return null;
}
@Override
public intgetCount(){
returnmFragment.size();
}
@Override
publicCharSequencegetPageTitle(intposition){
returnmFragment.get(position).getTitle();
}
}