Android顶部用tabLayout和viewPager显示二级分类

activity1:

DingdanPagerAdapter adapter = new DingdanPagerAdapter(getSupportFragmentManager(),
        new String[]{"我的","团队"});
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);

fragment1:

DingdanAdapter adapter = new DingdanAdapter(getChildFragmentManager(),
        new String[]{"全部状态","已结算","有效","无效"});
adapter.setFlagType(flag,type);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);

注意activity嵌套fragment,使用的管理者

getSupportFragmentManager()

fragment嵌套fragment,使用的管理者

getChildFragmentManager()

 

你可能感兴趣的:(android)