[英]Android tabs, how to show image for selected tab
the current code shows colors the selected tab. 当前代码显示所选标签的颜色。 I would like to change it to now show an image instead. 我想将其更改为现在显示图像。 the commented out code is what I thought would work and not sure why it does not. 被注释掉的代码是我认为可以使用的代码,但不确定为什么不起作用。 what should it be ???? 应该是什么???
Many thanks. 非常感谢。
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
for(int i=0;i<mTabHost.getTabWidget().getChildCount();i++)
{
TabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#404040"));
//what I thought would work is this below ?????
//mTabHost.getTabWidget().getChildAt(i).getResources().getDrawable(R.drawable.tabimg);
}
mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#271B1B"));
}
what have I missed. 我错过了什么。 Thx Again. 再次感谢。
Got it. 得到它了。 Found my mistake ....silly of me. 发现我的错误。 I should have used setBackgroundResource. 我应该使用setBackgroundResource。
mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tabimg);
works now. 现在工作。 thx. 谢谢。
Hope this helps someone. 希望这对某人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.