I want to change the icon tabs. I have icons on each drawable folder and my xml selector file in each drawable folder .
View 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.
It is supposed to be R.drawable.ic_casa not 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.* refers to resources of android itself R.* are your own resources
So use R.drawable.ic_casa instead
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.