the TabLayout, added dynamically is TabLayout, at the top and ViewPager, at the bottom. TabLayout is selected by default, and ViewPager at the bottom is selected, but why is the third
dynamically loaded code and TabLayout selected listening code:
@Override
public void onSuccess(List<GameType> gameTypes, String msg) {
mGameTypes = gameTypes;
for (int i = 0; i < gameTypes.size(); iPP) {
GameType gameType = gameTypes.get(i);
String title = gameType.getEname();
SchedulePageFragment gamePageFragment = new SchedulePageFragment();
FragmentPage fragmentPage = new FragmentPage(gamePageFragment, title);//
TabLayout.Tab tab = mTabLayout.newTab();
mTabLayout.addTab(tab);//tablayout
mPageList.add(fragmentPage);//ViewPager
if (i == 2) {
mTabLayout.getTabAt(2).select();
}
}
BaseFragmentPagerAdapter adapter = new BaseFragmentPagerAdapter(getChildFragmentManager(), mPageList);
mViewPager.setAdapter(adapter);
mTabLayout.setupWithViewPager(mViewPager);
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
int position = tab.getPosition();//TabLayout,
// mViewPager.setCurrentItem(position);
// mTabLayout.getTabAt(position).select();//
if (mGameTypes != null) {
GameType gameType = mGameTypes.get(position);
String eid = gameType.getEid();
App.getApplication().getMap().put("eid", eid);//eid
Log.d(TAG, "onTabSelected: 1624=" + eid);
}
}