Hi, I have 2 questions regarding tabHost: I've created tabHost with 2 tabs and for the tab titles I use setIndicator(TextView) (I work with api level 4) my title background is white. I use selector for the title to choose between diff images for the title.
I want to make the title text bold only when selected/pressed. I didn't succeed to do it using the selector I have. can I do it at all? the idea is that on cases I use drawable a I want the text bold. other cases not bold. same question regarding textColor.
it looks like a bug - when the tab first opens, the text on the selected tab (the one I used in tabHost.setCurrentTab(tabId)) is not seen at all. after first press/focus/focus any other item it looks well. any idea why or how to solve this?
thanks in advance
on tabActivity -
TextView title1 = new TextView(MainActivity.getInstnace(), null, android.graphics.Typeface.NORMAL);
TextView title2 = new TextView(MainActivity.getInstnace(), null, android.graphics.Typeface.NORMAL);
title1.setText("teb11 title"); title1.setBackgroundResource(R.drawable.tabtitle); title1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.tab1), null, null, null);
title2.setText("tab22 title"); title2.setBackgroundResource(R.drawable.tabtitle); title2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.tab2) null, null, null);
TabSpec tab1 = mTabHost.newTabSpec("tab1").setIndicator(title1).setContent(R.id.list1);
TabSpec tab2 = mTabHost.newTabSpec("tab2").setIndicator(title2).setContent(R.id.list2);
mTabHost.addTab(tab1);
mTabHost.addTab(tab2);
mTabHost.setCurrentTab(0);
the selector tab1.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@drawable/iconselect"/>
<item android:state_pressed="true"
android:drawable="@drawable/iconselect"/>
<item android:drawable="@drawable/icon"/>
</selector>
the selector for tabTitle
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/tabselected"/>
<item android:state_selected="true"
android:drawable="@drawable/tab" />
<item android:state_focused="true"
android:drawable="@drawable/tab" />
</selector>