Bradley S. O'Hearne wrote: > I have a tab bar for which I've set the initial icons and labels as > necessary. I have also hooked the onTabChanged callback of the > TabHost such that I'm properly getting notified when a user selects a > tab. > > However, I've now discovered that there's not direct way to change > the indicator of a tab. Can anyone enlighten me as to how the > indicator icon can be changed on a tab when selected, and I'd like to > do this programmatically (i.e. not in XML preferably). > > There must be some way of doing this, given the Android developer > docs set forth specs on selected states for tab icons.
Well, the recommended approach is to use a StateListDrawable for the tab icon, so it changes its look based on selected/not-selected and such. As you have notices, there is no API to change the tab once it has been defined. You can navigate the view hierarchy with a well-crafted set of findViewById() calls to get to the ImageView, but this will be fragile -- if they change the implementation in a future edition of Android, you're screwed. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

