I have a TabbedView Activity with 3 tabs. Currently, only the 1st tab has its correct icon, and the other 2 are blank.
My xml file is as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/news" android:state_selected="true" />
<item android:drawable="@drawable/score" android:state_selected="true" />
<item android:drawable="@drawable/schedule" android:state_selected="true" />
</selector>
The news icon is the one that shows up. Here is my tabbed view activity. I was expecting to see the 2nd tab icon be the score icon, and the 3rd tab be the schedule Icon:
//Headlines
intent = new Intent().setClass(this, HeadlineBoard.class);
intent.putExtra(Constants.SPORT_NAME_EXTRA, sportsName);
intent.putExtra(Constants.HEADLINES_FOR_SPORT_EXTRA, headlines);
spec = tabHost.newTabSpec("news").setIndicator("Headlines",
res.getDrawable(R.drawable.hl_aggie))
.setContent(intent);
tabHost.addTab(spec);
//Scores
intent = new Intent().setClass(this, ScoreBoard.class);
intent.putExtra(Constants.SPORT_NAME_EXTRA, sportsName);
intent.putExtra(Constants.SCORES_FOR_SPORT_EXTRA, scores);
spec = tabHost.newTabSpec("score").setIndicator("Scores",
res.getDrawable(R.drawable.hl_aggie))
.setContent(intent);
tabHost.addTab(spec);
//Schedule
intent = new Intent().setClass(this, ScheduleBoard.class);
intent.putExtra(Constants.SPORT_NAME_EXTRA, sportsName);
intent.putExtra(Constants.SCHEDULE_FOR_SPORT_EXTRA, scheduleIn);
spec = tabHost.newTabSpec("schedule").setIndicator("Schedule",
res.getDrawable(R.drawable.hl_aggie))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
if you just want all the icon to show up, why don’t you just set all the icon drawables respectively to each tab ?
TabSpec scoreSpec= tabHost.newTabSpec("score");scoreSpec.setIndicator("scores", getResources().getDrawable(R.drawable.score));Here is the Reference..