[英]change tab icon android project
I want to change the icon tabs. 我想更改图标选项卡。 I have icons on each drawable folder and my xml selector file in each drawable folder . 我在每个drawable文件夹上都有图标,在每个drawable文件夹中都有xml选择器文件。
View XML: 查看XML:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_selected="true"
android:drawable="@drawable/ic_casa_selected" />
<item
android:state_selected="false"
android:drawable="@drawable/ic_casa_unselected" />
</selector>
and this code: 和此代码:
TabHost.TabSpec spec=tabs.newTabSpec("mitab1");
spec.setContent(R.id.tab1);
spec.setIndicator("TAB1",
res.getDrawable(android.R.drawable.ic_casa));
tabs.addTab(spec);
Android cannot find the icon. Android无法找到该图标。
It is supposed to be R.drawable.ic_casa not android.R.drawable.ic_casa. 应该是R.drawable.ic_casa而不是android.R.drawable.ic_casa。 Another solution, did you tried to Cleaning and Building the project? 另一个解决方案,您是否尝试过清理和构建项目? Go to Project > Clean and clean your project. 转到项目>清理并清理您的项目。 Then try running it again. 然后尝试再次运行它。
android.R.* is not the same as R.* android.R。*与R. *不同
android.R.* refers to resources of android itself R.* are your own resources android.R。*指的是android R. *本身的资源
So use R.drawable.ic_casa instead 因此,请改用R.drawable.ic_casa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.