Reputation: 1639
I am following one book tutorial. While developing it, I come across a typical problem. I need to know that how should I change my content of a Tab while I move from one tab to another? thanks for any suggestions.
Upvotes: 1
Views: 355
Reputation: 67286
Here is a nice tutorial of TabActivity you are looking for,
For changing the icon of selected tab you have to create an xml for each tab like this in drawable folder
first_tab.xml
<item android:state_selected="false"
android:drawable="@drawable/tab_unselected_icon"/>
<item android:state_selected="true"
android:drawable="@drawable/tab_selected_icon"/>
</selector>
And the while creating tabs you have to use this xml like this,
intent = new Intent().setClass(this, Activity_name.class);
spec = tabHost.newTabSpec("yourTab_name").setIndicator("yourTab_name",res.getDrawable(R.drawable. first_tab)).setContent(intent);
tabHost.addTab(spec);
And you are done with it. Thanks.
Upvotes: 1