rogcg
rogcg

Reputation: 10471

Change icon when focus and unfocus Android Tab widget

Hey I'd like to change the icon from the TabWidget on Android by focusing and unfocusing the tab. I mean, when I select the Tab, the icon shows for example green, and when I select the oter tab, the icon changes to red.

I'm calling a unique icon this way:

tabHost.addTab(tabHost.newTabSpec("one").setIndicator("Rated Calls", res.getDrawable(R.drawable.ratedcallicon))

How to make it change the image of the icon when I select other tab?

Thanks!

Upvotes: 2

Views: 1808

Answers (1)

EboMike
EboMike

Reputation: 77722

Every drawable has the ability to take up multiple images based on its current state (see how it has a setState member. You could use StateListDrawable, or even specify the states in XML.

There is a state for "focused", and FWIK that works on tabs.

Upvotes: 3

Related Questions