Tabbar图标未显示
我尝试更改res.getDrawble(R.drawble.ic_alarm)
但未显示。
我使用Fragment/ViewPager
,因此请FakeContent
tabHost = (TabHost)findViewById(R.id.tabHost);
tabHost.setup();
TabHost.TabSpec tabSpec;
Resources res = getResources();
tabSpec = tabHost.newTabSpec("Tab1");
tabSpec.setIndicator("Tab1", res.getDrawable(R.drawable.alarm));
tabSpec.setContent(new FakeContent(getApplicationContext()));
tabHost.addTab(tabSpec);
tabSpec = tabHost.newTabSpec("Tab2");
tabSpec.setIndicator("Tab2", getResources().getDrawable(R.drawable.ic_alarm));
tabSpec.setContent(new FakeContent(getApplicationContext()));
tabHost.addTab(tabSpec);
tabSpec = tabHost.newTabSpec("Tab3");
tabSpec.setIndicator("Tab3",getResources().getDrawable(R.drawable.ic_alarm));
tabSpec.setContent(new FakeContent(getApplicationContext()));
tabHost.addTab(tabSpec);
tabHost.setOnTabChangedListener(this);
XML ic_alarm
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/alarm" android:state_selected="true" />
</selector>