Android change Tab image (not backgound)
- by user1143989
I am using a TabHost which has 3 tabs. Each tab has a image + text.
spec = tabHost.newTabSpec("MyTasks")
.setIndicator(Html.fromHtml("<b><H2>My Tasks</H2></b>"), getResources().getDrawable(R.drawable.task ))
.setContent(intent);
tabHost.addTab(spec);
I want to change image when I select a tab. I used following code to change it ...
TabWidget tw = getTabWidget();
View leftTabView = tw.getChildAt(0);
leftTabView.setBackgroundDrawable(getResources().getDrawable(R.drawable.tab1_drawable));
tab1_drawable is a xml (selector and items for each state). THIS IS SETTING AND CHANGING BACKGROUND NOT THE IMAGE I SET. How can I change it?