How do I change the icon, when a tab is selected X?
I have a tabhost with icon, when a tab is selected X, the icon does not appear because the icon is the same c开发者_如何学运维olor as the selected tab. The question is:
How do I change the icon, when a tab is selected X?
This is what I have:
//TabActivity.onCreate()
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, YourClass.class);
spec = tabHost.newTabSpec("tab_name").setIndicator("Tab Text",
getResources().getDrawable(R.drawable.ic_tab_dialer))
.setContent(intent);
tabHost.addTab(spec);
Then, you need to add ic_tab_dialer.xml
to res/drawable/
directory with this content:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/ic_tab_selected_dialer" />
<item android:drawable="@drawable/ic_tab_unselected_dialer" />
</selector>
I downloaded the icons from Contacts app GIT repo.:
git://android.git.kernel.org/platform/packages/apps/Contacts.git
精彩评论