1
我已经关注了Tab视图的教程here。每个选项卡现在都有一个图像,但是当我选择一些选项卡时,它不会被替换为黑色图像。有一些我不知道的技巧。对于一个标签Forexample代码选项卡视图选中的图像不能正常工作
spec = tabHost.newTabSpec("create").setIndicator("Create",
res.getDrawable(R.drawable.testimg))
.setContent(intent);
tabHost.addTab(spec);
然后创建create.xml
与以下内容
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/testimg2"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/testimg" />
</selector>
所以,当我选择创建选项卡,然后它的形象应该被替换testimg2.png但它没有发生。其余的代码与教程类似。 我在这里遗漏的是选定的图像没有被切换。
感谢