I’m trying to do the Tab Layout tutorial and my code crashes because of “Source not found”
on the lines :
intent = new Intent().setClass(this, FavouritesActivity.class);
spec = tabHost.newTabSpec("favourites").setIndicator("favourites",
res.getDrawable(R.drawable.ic_tab_favourites))
.setContent(intent);
tabHost.addTab(spec);
and to be more specific it crashes on :
res.getDrawable(R.drawable.ic_tab_favourites)
I do have a class named FavouritesActivity and ic_tab_favourites.xml file on res/drawable
(Eclipse even autocompletes those two…).
Any idea on what could be wrong ?
edit: I found that the code in ic_tab_favourites.xml is the problem, the code is:
<?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/ic_tab_favourites_gray"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_favourites_white" />
</selector>
and the problem is with the drawable resources “ic_tab_favourites_gray”, “ic_tab_favourites_white”.
but I don’t know why, Eclipse autocompletes them when I edit the .xml file and I do have
ic_tab_favourites_gray.ico,
ic_tab_favourites_white.ico
edit 2 : if for example I change the .xml to :
<?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/ic_tab_main_gray"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/ic_tab_main_gray" />
</selector>
than it works (but ofcourse I don’t want ic_tab_main_gray icon for this tab…)
have you used Resources res = getResources();
in tabs activity?