TabLayout selected Tab icon is not selected on start up

前端 未结 6 544
小鲜肉
小鲜肉 2021-01-17 14:14

I\'m using a TabLayout for Tabbed navigation in my app. I have a really weird issue with it, I have created 4 tabs using this code:

private int[         


        
6条回答
  •  不要未来只要你来
    2021-01-17 15:12

    Try selecting the tab after you've populated them.

    TabLayout tabLayout = setTabLayout();
    if (tabLayout != null) {
        for (int i = 0; i < 4; i++) {
            tabLayout.getTabAt(i).setIcon(tabIcons[i]);
        }
        tabLayout.getTabAt(0).select();
    }
    

提交回复
热议问题