I have a tabhost with icon, when a tab is selected X, the icon does not appear because the icon is the same color as the selected tab. 问题是:
选择选项卡时如何更改图标 X?
I have a tabhost with icon, when a tab is selected X, the icon does not appear because the icon is the same color as the selected tab. 问题是:
选择选项卡时如何更改图标 X?
这就是我所拥有的:
//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);
然后,您需要使用以下内容添加ic_tab_dialer.xml
到res/drawable/
目录:
<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>
我从 Contacts app GIT repo 下载了图标:
git://android.git.kernel.org/platform/packages/apps/Contacts.git