出于某种原因,我的标签没有显示出来。 我的播放器主页活动应显示两个选项卡,命名配置文件和团队,但它没有显示任何内容。并且没有显示任何错误。
OnCreate
玩家主页活动
mainAppToolBar = (android.support.v7.widget.Toolbar) findViewById(R.id.mainAppBar);
setSupportActionBar(mainAppToolBar);
getSupportActionBar().setTitle("Player Home");
playerTabLayout = (TabLayout) findViewById(R.id.playerMainTabs);
playerViewPager = (ViewPager) findViewById(R.id.playerMainTabPager);
playerSectionPageAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
playerViewPager.setAdapter(playerSectionPageAdapter);
playerTabLayout.setupWithViewPager(playerViewPager);
章节页面适配器的代码
public class SectionPageAdapter extends FragmentPagerAdapter {
public SectionPageAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
ProfileFragment profileFragment = new ProfileFragment();
return profileFragment;
case 1:
TeamFragment teamFragment = new TeamFragment();
return teamFragment;
default:
return null;
}
}
@Override
public int getCount() { return 2;}
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Profile";
case 1:
return "Teams";
default:
return null;
}
}}
请帮忙。
答案 0 :(得分:0)
getCount()
被覆盖,但我没有看到getPageTitle
。我认为你错过了@override
。
@Override
public int getCount() { return 2;}
@Override - add this
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Profile";
case 1:
return "Teams";
default:
return null;
}
}}