문제

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.

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top