设置适配器和Tab够用
adapter=newMyFragmentPagerAdapter(getChildFragmentManager());
mVpFrag.setAdapter(adapter);
mTab.setupWithViewPager(mVpFrag);
创建适配器
privateString[]mTitles=newString[]{"最新日报","专栏","热点","主题日报"};
publicMyFragmentPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
publicFragment getItem(intposition) {
if(position==1){
return newFragment_sy_zl();
}else if(position==2){
return newFragment_sy_rm();
}else if(position==3){
return newFragment_sy_ztrb();
}
return newFragment_sy_zxrb();
}
@Override
public intgetCount() {
returnmTitles.length;
}
@Override
publicCharSequencegetPageTitle(intposition) {
returnmTitles[position];
}