Question

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.

No correct solution

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top