Ask a question of adding TabLayout dynamically.

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

not selected in the top TabLayout?

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);
        }
    }
Mar.23,2021

in this loop for (int i = 0; I < gameTypes.size (); iPP)
mViewPager does not have adapter
so no matter how you set it in this loop, it doesn't work

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e52043-4372e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e52043-4372e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?