【发布时间】:2017-09-06 08:20:09
【问题描述】:
我正在创建一个 android studio 应用程序,当用户单击选项卡按钮时,我想要选项卡图标/颜色
更改这是我的代码:
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
int id= tabHost.getCurrentTab();
// TabLayout.setSelectedTabIndicatorColor(int color); // Error because of non static method
// if(id==0){
// TabHost.TabSpec tab1spec = tabHost.newTabSpec("List");
// tab1spec.setIndicator("", getResources().getDrawable(R.drawable.home2));
// }
// if(id==1){
// TabHost.TabSpec tab1spec = tabHost.newTabSpec("Config");
// tab1spec.setIndicator("", getResources().getDrawable(R.drawable.lab2));
// }
// if(id==2){
// TabHost.TabSpec tab1spec = tabHost.newTabSpec("More");
// tab1spec.setIndicator("", getResources().getDrawable(R.drawable.more2));
// }
}
});
有什么想法吗?
谢谢
【问题讨论】:
标签: java android android-tabhost