Open NeptuneCoder opened 7 years ago
我设置了setupWithViewPager后,指示器显示,但是标题不显示。 然后我通过如下设置: mVpProduct.setAdapter(productFragmentAdapter); tabLayout.setupWithViewPager(mVpProduct); productFragmentAdapter.notifyDataSetChanged(); tabLayout.addTab(tabLayout.newTab().setText("火爆专区")); tabLayout.addTab(tabLayout.newTab().setText("固收理财")); tabLayout.addTab(tabLayout.newTab().setText("转让专区"));
指示器的位置和标题的位置错乱!
找到原因了!在populateFromPagerAdapter 方法中,调用了removeAllTabs()方法。 我titleName通过Adapter中的getPageTitle方法设置就没有问题了。
我设置了setupWithViewPager后,指示器显示,但是标题不显示。 然后我通过如下设置: mVpProduct.setAdapter(productFragmentAdapter); tabLayout.setupWithViewPager(mVpProduct); productFragmentAdapter.notifyDataSetChanged(); tabLayout.addTab(tabLayout.newTab().setText("火爆专区")); tabLayout.addTab(tabLayout.newTab().setText("固收理财")); tabLayout.addTab(tabLayout.newTab().setText("转让专区"));
指示器的位置和标题的位置错乱!