Android change Tab image (not backgound)

Posted by user1143989 on Stack Overflow See other posts from Stack Overflow or by user1143989
Published on 2012-04-05T17:12:44Z Indexed on 2012/04/05 17:30 UTC
Read the original article Hit count: 127

Filed under:

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?

© Stack Overflow or respective owner

Related posts about android