以编程方式更改选项卡文本的颜色我已经开发tabbedview与每个单独的选项卡的自定义布局。现在当我选择一个选项卡其他选项卡图标应该更改,我想更改其他标签文本的颜色。请帮忙?在选项卡选择更改其他选项卡图标,并在android
这里是我的代码:
final TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setCustomView(R.layout.custom_tab_one));
tabLayout.addTab(tabLayout.newTab().setCustomView(R.layout.custom_tab_two));
tabLayout.addTab(tabLayout.newTab().setCustomView(R.layout.custom_tab_three));
tabLayout.addTab(tabLayout.newTab().setCustomView(R.layout.custom_tab_four));
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final TabViewAdapter adapter = new TabViewAdapter(getSupportFragmentManager(),tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
请加上您的代码 –